Zelda Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2023-11-12 03:48:08
Exec Total Coverage
Lines: 8555 12275 69.7%
Functions: 327 399 82.0%
Branches: 6721 13690 49.1%

Line Branch Exec Source
1 #include <cstring>
2 #include <stdio.h>
3 #include "base/zc_alleg.h"
4 #include "zc/guys.h"
5 #include "zc/replay.h"
6 #include "zc/zc_ffc.h"
7 #include "zc/zelda.h"
8 #include "base/zsys.h"
9 #include "base/msgstr.h"
10 #include "zc/maps.h"
11 #include "zc/hero.h"
12 #include "subscr.h"
13 #include "zc/ffscript.h"
14 #include "gamedata.h"
15 #include "defdata.h"
16 #include "zscriptversion.h"
17 #include "particles.h"
18 #include "base/zc_math.h"
19 #include "slopes.h"
20 #include "base/qrs.h"
21 #include "base/dmap.h"
22 #include "base/mapscr.h"
23 #include "base/misctypes.h"
24 #include "base/initdata.h"
25 extern particle_list particles;
26
27 extern FFScript FFCore;
28 extern ZModule zcm;
29 extern HeroClass Hero;
30 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
31
32 int32_t repaircharge=0;
33 bool adjustmagic=false;
34 bool learnslash=false;
35 int32_t wallm_load_clk=0;
36 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
37 int32_t vhead=0;
38 int32_t guycarryingitem=0;
39
40 char *guy_string[eMAXGUYS];
41
42 void never_return(int32_t index);
43 void playLevelMusic();
44
45 // If an enemy is this far out of the playing field, just remove it.
46 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
47 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
48 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
49 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
50
51 648969 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
52 {
53 648969 int32_t c = coord.getInt();
54
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 648702 times.
648969 if(nearest_half)
55 {
56
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 648702 times.
648702 if (c < 0)
57 c -= val / 2;
58 648702 else c += (val/2);
59 648702 }
60 648969 c -= c % val;
61 648969 coord = c;
62 648969 }
63
64 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
65 {
66 return
67 (
68 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
69 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
70 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
71 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
72 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
73 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
74 );
75 }
76
77 namespace
78 {
79 int32_t trapConstantHorizontalID;
80 int32_t trapConstantVerticalID;
81 int32_t trapLOSHorizontalID;
82 int32_t trapLOSVerticalID;
83 int32_t trapLOS4WayID;
84
85 int32_t cornerTrapID;
86 int32_t centerTrapID;
87
88 int32_t rockID;
89 int32_t zoraID;
90 int32_t statueID;
91 }
92
93 123 void identifyCFEnemies()
94 {
95 123 trapConstantHorizontalID=-1;
96 123 trapConstantVerticalID=-1;
97 123 trapLOSHorizontalID=-1;
98 123 trapLOSVerticalID=-1;
99 123 trapLOS4WayID=-1;
100 123 cornerTrapID=-1;
101 123 centerTrapID=-1;
102 123 rockID=-1;
103 123 zoraID=-1;
104 123 statueID=-1;
105
106
2/2
✓ Branch 0 taken 62976 times.
✓ Branch 1 taken 123 times.
63099 for(int32_t i=0; i<eMAXGUYS; i++)
107 {
108
3/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 62854 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
62976 if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1)
109 122 trapLOSHorizontalID=i;
110
4/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 62850 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 123 times.
62976 if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1)
111 123 trapLOSVerticalID=i;
112
3/4
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 62853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
62976 if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1)
113 123 trapLOS4WayID=i;
114
3/4
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 62853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
62976 if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1)
115 123 trapConstantHorizontalID=i;
116
3/4
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 62853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
62976 if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1)
117 123 trapConstantVerticalID=i;
118
119
3/4
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 62853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
62976 if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1)
120 123 cornerTrapID=i;
121
3/4
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 62853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
62976 if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1)
122 123 centerTrapID=i;
123
124
3/4
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 62853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123 times.
62976 if((guysbuf[i].flags2&eneflag_rock) && rockID==-1)
125 123 rockID=i;
126
4/4
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 62848 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 123 times.
62976 if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1)
127 123 zoraID=i;
128
129
4/4
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 62847 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 123 times.
62976 if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1)
130 123 statueID=i;
131 62976 }
132 123 }
133
134 25 int32_t random_layer_enemy()
135 {
136 25 int32_t cnt=count_layer_enemies();
137
138
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(cnt==0)
139 {
140 return eNONE;
141 }
142
143 25 int32_t ret=zc_oldrand()%cnt;
144 25 cnt=0;
145
146
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 for(int32_t i=0; i<6; ++i)
147 {
148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tmpscr->layermap[i]!=0)
149 {
150 25 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
151
152
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 for(int32_t j=0; j<10; ++j)
153 {
154
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
155 {
156
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102 times.
127 if(cnt==ret)
157 {
158 25 return layerscreen->enemy[j];
159 }
160
161 102 ++cnt;
162 102 }
163 102 }
164 }
165 }
166
167 return eNONE;
168 25 }
169
170 39 int32_t count_layer_enemies()
171 {
172 39 int32_t cnt=0;
173
174
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 39 times.
273 for(int32_t i=0; i<6; ++i)
175 {
176
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 39 times.
234 if(tmpscr->layermap[i]!=0)
177 {
178 39 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
179
180
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 39 times.
429 for(int32_t j=0; j<10; ++j)
181 {
182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if(layerscreen->enemy[j]!=0)
183 {
184 390 ++cnt;
185 390 }
186 390 }
187 39 }
188 234 }
189
190 39 return cnt;
191 }
192
193 145542 int32_t hero_on_wall()
194 {
195 145542 zfix lx = Hero.getX();
196 145542 zfix ly = Hero.getY();
197
198
199 //zprint2("hero_on_wall x is: %d\n", lx);
200 //zprint2("hero_on_wall y is: %d\n", ly);
201
202
4/4
✓ Branch 0 taken 135889 times.
✓ Branch 1 taken 9653 times.
✓ Branch 2 taken 4526 times.
✓ Branch 3 taken 131363 times.
145542 if(lx>=48 && lx<=192)
203 {
204
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 131211 times.
131363 if(ly==32) return up+1;
205
206
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 131051 times.
131211 if(ly==128) return down+1;
207 131051 }
208
209
4/4
✓ Branch 0 taken 134471 times.
✓ Branch 1 taken 10759 times.
✓ Branch 2 taken 11441 times.
✓ Branch 3 taken 123030 times.
145230 if(ly>=48 && ly<=112)
210 {
211
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 122898 times.
123030 if(lx==32) return left+1;
212
213
2/2
✓ Branch 0 taken 122829 times.
✓ Branch 1 taken 69 times.
122898 if(lx==208) return right+1;
214 122829 }
215
216 145029 return 0;
217 145542 }
218
219 690683 bool tooclose(int32_t x,int32_t y,int32_t d)
220 {
221
2/2
✓ Branch 0 taken 511179 times.
✓ Branch 1 taken 179504 times.
690683 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
222 }
223
224 2107695 bool enemy::overpit(enemy *e)
225 {
226 // This function (and shadow_overpit) has been broken since it was written, and only
227 // checked the same diagonal of the hitbox, over and over again. The bug is because both
228 // loops used the same variable name.
229 // Checking literally every pixel seems like overkill, so for now let's continue to
230 // do the single diagonal but just once. That's why the outer loop is commented out.
231
232 // for ( int32_t q = 0; q < hxsz; ++q )
233 {
234
2/2
✓ Branch 0 taken 19856068 times.
✓ Branch 1 taken 2104527 times.
21960595 for ( int32_t q = 0; q < hit_height; ++q )
235 {
236 //check every pixel of the hitbox
237
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 19852900 times.
19856068 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
238 {
239 //if the hitbox is over a pit, we can't land
240 3168 return true;
241 }
242 19852900 }
243 }
244 2104527 return false;
245 2107695 }
246
247 4518811 bool enemy::shadow_overpit(enemy *e)
248 {
249 // for ( int32_t q = 0; q < hxsz; ++q )
250 {
251
2/2
✓ Branch 0 taken 66532458 times.
✓ Branch 1 taken 4514959 times.
71047417 for ( int32_t q = 0; q < hit_height; ++q )
252 {
253 //check every pixel of the hitbox
254
2/2
✓ Branch 0 taken 3852 times.
✓ Branch 1 taken 66528606 times.
66532458 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
255 {
256 //if the hitbox is over a pit, we can't land
257 3852 return true;
258 }
259 66528606 }
260 }
261 4514959 return false;
262 4518811 }
263
264 // Returns true iff a combo type or flag precludes enemy movement.
265 3797440 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
266 {
267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3797440 times.
3797440 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
268 3797440 int32_t c = COMBOTYPE(dx,dy);
269
4/4
✓ Branch 0 taken 2492540 times.
✓ Branch 1 taken 1304900 times.
✓ Branch 2 taken 656349 times.
✓ Branch 3 taken 648551 times.
5102340 bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
270
3/6
✓ Branch 0 taken 1291100 times.
✓ Branch 1 taken 2506340 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1291100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3797440 bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_qr(qr_DROWN));
271
4/6
✓ Branch 0 taken 1326577 times.
✓ Branch 1 taken 2470863 times.
✓ Branch 2 taken 1326577 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1326577 times.
✗ Branch 5 not taken.
7595483 return c==cPIT || c==cPITB || c==cPITC ||
272
4/6
✓ Branch 0 taken 1326577 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1326577 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1237082 times.
✓ Branch 5 taken 89495 times.
1326577 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
273 // Block enemies type and block enemies flags
274
2/2
✓ Branch 0 taken 1325228 times.
✓ Branch 1 taken 1235733 times.
89495 combo_class_buf[c].block_enemies&1 ||
275
3/4
✓ Branch 0 taken 1325225 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1325225 times.
✗ Branch 3 not taken.
1325228 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
276
4/4
✓ Branch 0 taken 1324901 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 1324888 times.
✓ Branch 3 taken 13 times.
1325225 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
277 // Check for ladder-only combos which aren't dried water
278
4/4
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 1324294 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 5 times.
2649771 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
279 // Check for drownable water
280
4/4
✓ Branch 0 taken 103121 times.
✓ Branch 1 taken 1221762 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 101221 times.
1324883 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
281 1327180 }
282
283 // Returns true iff enemy is floating and blocked by a combo type or flag.
284 4618347 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
285 {
286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4618347 times.
4618347 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
287
4/4
✓ Branch 0 taken 2869530 times.
✓ Branch 1 taken 1748817 times.
✓ Branch 2 taken 1521446 times.
✓ Branch 3 taken 227371 times.
6367164 bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
288
3/4
✓ Branch 0 taken 2879534 times.
✓ Branch 1 taken 1738813 times.
✓ Branch 2 taken 1738813 times.
✗ Branch 3 not taken.
6357160 bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB));
289
2/2
✓ Branch 0 taken 557276 times.
✓ Branch 1 taken 4061071 times.
8679418 return ((special==spw_floater)&&
290
2/2
✓ Branch 0 taken 4054933 times.
✓ Branch 1 taken 6138 times.
4061071 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
291
1/2
✓ Branch 0 taken 4054933 times.
✗ Branch 1 not taken.
4054933 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
292
2/2
✓ Branch 0 taken 4054796 times.
✓ Branch 1 taken 137 times.
4054933 (MAPFLAG(dx,dy)==mfNOENEMY)||
293
1/2
✓ Branch 0 taken 4054796 times.
✗ Branch 1 not taken.
4054796 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
294
4/4
✓ Branch 0 taken 1240951 times.
✓ Branch 1 taken 2813845 times.
✓ Branch 2 taken 3939 times.
✓ Branch 3 taken 1237012 times.
8105653 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
295
2/2
✓ Branch 0 taken 2807382 times.
✓ Branch 1 taken 1243475 times.
4050857 (pit_blocks && ispitfall(dx,dy))));
296 4618347 }
297 // Returns true iff a combo type or flag precludes enemy movement.
298 242814 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
299 {
300 242814 int32_t c = COMBOTYPE(dx,dy);
301 242814 bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK);
302
2/2
✓ Branch 0 taken 27325 times.
✓ Branch 1 taken 215489 times.
242814 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_qr(qr_DROWN);
303
4/6
✓ Branch 0 taken 242813 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 242813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242813 times.
✗ Branch 5 not taken.
922963 return c==cPIT || c==cPITB || c==cPITC ||
304
4/6
✓ Branch 0 taken 242813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 218778 times.
✓ Branch 5 taken 24035 times.
242813 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
305 // Block enemies type and block enemies flags
306
2/2
✓ Branch 0 taken 242703 times.
✓ Branch 1 taken 218668 times.
24035 combo_class_buf[c].block_enemies&1 ||
307
3/4
✓ Branch 0 taken 242555 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 242555 times.
✗ Branch 3 not taken.
242703 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
308
4/4
✓ Branch 0 taken 239059 times.
✓ Branch 1 taken 3496 times.
✓ Branch 2 taken 238787 times.
✓ Branch 3 taken 272 times.
242555 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
309 // Check for ladder-only combos which aren't dried water
310
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 238756 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
477574 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
311 // Check for drownable water
312
4/4
✓ Branch 0 taken 32351 times.
✓ Branch 1 taken 206436 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 8347 times.
238787 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
313 }
314
315 // Returns true iff enemy is floating and blocked by a combo type or flag.
316 115623 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
317 {
318
2/2
✓ Branch 0 taken 113300 times.
✓ Branch 1 taken 2323 times.
115623 bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL));
319 115623 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK);
320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115623 times.
231246 return ((special==spw_floater)&&
321
2/2
✓ Branch 0 taken 115621 times.
✓ Branch 1 taken 2 times.
115623 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
322
1/2
✓ Branch 0 taken 115621 times.
✗ Branch 1 not taken.
115621 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
323
2/2
✓ Branch 0 taken 115617 times.
✓ Branch 1 taken 4 times.
115621 (MAPFLAG(dx,dy)==mfNOENEMY)||
324
1/2
✓ Branch 0 taken 115617 times.
✗ Branch 1 not taken.
115617 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
325
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 113296 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
230984 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
326
2/2
✓ Branch 0 taken 113296 times.
✓ Branch 1 taken 2071 times.
115367 (pit_blocks && ispitfall(dx,dy))));
327 }
328
329 /**********************************/
330 /******* Enemy Base Class *******/
331 /**********************************/
332
333
4/8
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58115 times.
✗ Branch 7 not taken.
116230 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
334 58115 {
335
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 x=X;
336
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 y=Y;
337 58115 id=Id;
338 58115 clk=Clk;
339
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 floor_y=y;
340 58115 ceiling=false;
341 58115 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
342 58115 grumble = movestatus = posframe = timer = ox = oy = 0;
343
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
58115 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
344 58115 did_armos=true;
345 58115 script_spawned=false;
346
347 58115 d = guysbuf + (id & 0xFFF);
348 58115 hp = d->hp;
349 58115 starting_hp = hp;
350 // cs = d->cset;
351 //d variables
352
353 58115 flags=d->flags;
354 58115 flags2=d->flags2;
355 58115 s_tile=d->s_tile; //secondary (additional) tile(s)
356 58115 family=d->family;
357 58115 dcset=d->cset;
358 58115 cs=dcset;
359
2/2
✓ Branch 0 taken 38815 times.
✓ Branch 1 taken 19300 times.
58115 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
360 58115 dp=d->dp;
361 58115 wdp=d->wdp;
362 58115 wpn=d->weapon;
363 58115 wpnsprite = d-> wpnsprite; //2.6 -Z
364 58115 rate=d->rate;
365 58115 hrate=d->hrate;
366
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 dstep=d->step;
367 58115 homing=d->homing;
368 58115 dmisc1=d->misc1;
369 58115 dmisc2=d->misc2;
370 58115 dmisc3=d->misc3;
371 58115 dmisc4=d->misc4;
372 58115 dmisc5=d->misc5;
373 58115 dmisc6=d->misc6;
374 58115 dmisc7=d->misc7;
375 58115 dmisc8=d->misc8;
376 58115 dmisc9=d->misc9;
377 58115 dmisc10=d->misc10;
378 58115 dmisc11=d->misc11;
379 58115 dmisc12=d->misc12;
380 58115 dmisc13=d->misc13;
381 58115 dmisc14=d->misc14;
382 58115 dmisc15=d->misc15;
383 58115 dmisc16=d->misc16;
384 58115 dmisc17=d->misc17;
385 58115 dmisc18=d->misc18;
386 58115 dmisc19=d->misc19;
387 58115 dmisc20=d->misc20;
388 58115 dmisc21=d->misc21;
389 58115 dmisc22=d->misc22;
390 58115 dmisc23=d->misc23;
391 58115 dmisc24=d->misc24;
392 58115 dmisc25=d->misc25;
393 58115 dmisc26=d->misc26;
394 58115 dmisc27=d->misc27;
395 58115 dmisc28=d->misc28;
396 58115 dmisc29=d->misc29;
397 58115 dmisc30=d->misc30;
398 58115 dmisc31=d->misc31;
399 58115 dmisc32=d->misc32;
400
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 57679 times.
58115 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
401 {
402 57679 dmisc31 = dmisc32;
403 57679 dmisc32 = 0;
404 57679 }
405 58115 spr_shadow=d->spr_shadow;
406 58115 spr_death=d->spr_death;
407 58115 spr_spawn=d->spr_spawn;
408
409
2/2
✓ Branch 0 taken 2382715 times.
✓ Branch 1 taken 58115 times.
2440830 for(int32_t i=0; i<edefLAST255; i++)
410 2382715 defense[i]=d->defense[i];
411
412 58115 bgsfx=d->bgsfx;
413 58115 hitsfx=d->hitsfx;
414 58115 deadsfx=d->deadsfx;
415 58115 bosspal=d->bosspal;
416 58115 parent_script_UID = 0;
417
418 58115 frozentile = d->frozentile;
419
420 58115 frozencset = d->frozencset;
421 58115 frozenclock = 0;
422
2/2
✓ Branch 0 taken 581150 times.
✓ Branch 1 taken 58115 times.
639265 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
423
424
2/2
✓ Branch 0 taken 987955 times.
✓ Branch 1 taken 58115 times.
1046070 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
425 //firesfx = 0; //t.b.a -Z
426 58115 isCore = true; //t.b.a
427 58115 parentCore = 0; //t.b.a
428
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
429
430 58115 firesfx = d->firesfx;
431
2/2
✓ Branch 0 taken 1859680 times.
✓ Branch 1 taken 58115 times.
1917795 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
432
2/2
✓ Branch 0 taken 1859680 times.
✓ Branch 1 taken 58115 times.
1917795 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
433
434
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data.
435 58115 waitdraw = 0;
436
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data.
437
438
2/2
✓ Branch 0 taken 464920 times.
✓ Branch 1 taken 58115 times.
523035 for ( int32_t q = 0; q < 8; q++ )
439 {
440 464920 initD[q] = d->initD[q];
441 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
442 464920 weap_initiald[q] = d->weap_initiald[q];
443 //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]);
444 //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]);
445 //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]);
446 464920 }
447
2/2
✓ Branch 0 taken 116230 times.
✓ Branch 1 taken 58115 times.
174345 for ( int32_t q = 0; q < 2; q++ )
448 {
449 116230 initA[q] = d->initA[q];
450 116230 weap_initiala[q] = d->weap_initiala[q];
451 116230 }
452
453 58115 stickclk = 0;
454 58115 submerged = false;
455 58115 didScriptThisFrame = false;
456 58115 ffcactivated = 0;
457 58115 hitdir = -1;
458 58115 dialogue_str = 0; //set by spawn flags.
459 58115 editorflags = d->editorflags; //set by Enemy Editor
460 //Set the drawing flag for this sprite.
461
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
462
463
464
2/2
✓ Branch 0 taken 49884 times.
✓ Branch 1 taken 8231 times.
58115 if(bosspal>-1)
465 {
466
1/2
✓ Branch 0 taken 8231 times.
✗ Branch 1 not taken.
8231 loadpalset(csBOSS,pSprite(bosspal));
467 8231 }
468
469
2/2
✓ Branch 0 taken 26009 times.
✓ Branch 1 taken 32106 times.
58115 if(bgsfx>-1)
470 {
471
1/2
✓ Branch 0 taken 26009 times.
✗ Branch 1 not taken.
26009 cont_sfx(bgsfx);
472 26009 }
473
474
2/2
✓ Branch 0 taken 38815 times.
✓ Branch 1 taken 19300 times.
58115 if(get_qr(qr_NEWENEMYTILES))
475 {
476 38815 o_tile=d->e_tile;
477 38815 frate = d->e_frate;
478 38815 }
479 else
480 {
481 19300 o_tile=d->tile;
482 19300 frate = d->frate;
483 }
484
485 58115 tile=0; //init to 0 here, but set it later.
486
487 58115 scripttile = -1;
488 58115 scriptflip = -1;
489 58115 do_animation = 1;
490 58115 immortal = false;
491 58115 noSlide = false;
492 58115 deathexstate = -1;
493
494 58115 hashero=false;
495
496 // If they forgot the invisibility flag, here's another failsafe:
497
4/4
✓ Branch 0 taken 2858 times.
✓ Branch 1 taken 55257 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 2764 times.
58115 if(o_tile==0 && family!=eeSPINTILE)
498 2764 flags |= guy_invisible;
499
500 // step = d->step/100.0;
501 // To preserve the odd step values for Keese & Gleeok heads. -L
502
5/8
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6746 times.
✓ Branch 5 taken 51369 times.
✓ Branch 6 taken 6746 times.
✗ Branch 7 not taken.
58115 if(dstep==62.0) dstep+=0.5;
503
5/8
✓ Branch 0 taken 51369 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 360 times.
✓ Branch 5 taken 51009 times.
✓ Branch 6 taken 360 times.
✗ Branch 7 not taken.
51369 else if(dstep==89) dstep-=1/9;
504
505
5/10
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58115 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58115 times.
✗ Branch 9 not taken.
58115 step = zslongToFix(dstep*100);
506
507
508 58115 item_set = d->item_set;
509 58115 grumble = d->grumble;
510
511
2/2
✓ Branch 0 taken 45387 times.
✓ Branch 1 taken 12728 times.
58115 if(frate == 0)
512 12728 frate = 256;
513
514 58115 leader = itemguy = dying = scored = false;
515 58115 canfreeze = count_enemy = true;
516 58115 mainguy = !(flags & guy_doesntcount);
517
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 dir = zc_oldrand()&3;
518
519 //2.6 Enemy Editor Hit and TIle Sizes
520
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
521 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
522 // al_trace("Enemy txsz:%i\n", txsz);
523
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
525
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
527
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
528
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
529 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
532 {
533 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
534 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
535 }
536
537
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
538
539 58115 SIZEflags = d->SIZEflags;
540
541
8/10
✓ Branch 0 taken 58027 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 58027 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 87 times.
58115 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
542 1 wpn = 0;
543
544 //tile should never be 0 after init --Z (failsafe)
545
4/6
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57108 times.
✓ Branch 5 taken 1007 times.
58115 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
546
547 //Moveflags; for gravity and pit interaction
548 58115 moveflags = d->moveflags;
549
3/4
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50647 times.
✓ Branch 3 taken 7468 times.
58115 if(!can_pitfall(false))
550 {
551 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
552 7468 moveflags &= ~FLAG_CAN_PITFALL;
553 7468 moveflags &= ~FLAG_CAN_WATERDROWN;
554 7468 }
555
556 58115 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
557 58115 }
558
559 598 int32_t enemy::getScriptUID() { return script_UID; }
560 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
561 57970 enemy::~enemy()
562 57970 {
563
2/4
✓ Branch 0 taken 57970 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57970 times.
✗ Branch 3 not taken.
57970 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
564
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 57966 times.
57970 if(hashero)
565 {
566
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 Hero.setEaten(0);
567 4 hashero=false;
568 4 }
569 57970 }
570
571
572 bool enemy::is_move_paused()
573 {
574 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
575 }
576
577 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
578 {
579 int32_t yg = (special==spw_floater)?8:0;
580 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
581 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
582 if(input_x == -1000)
583 input_x = dx;
584 if(input_y == -1000)
585 input_y = dy;
586
587 if(!(moveflags & FLAG_IGNORE_SCREENEDGE)
588 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
589 || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb))))
590 return true;
591
592 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
593 {
594 if(ispitfall(dx,dy))
595 return true;
596 }
597
598 bool flying = false;
599 bool cansolid = false;
600 if(moveflags & FLAG_IGNORE_SOLIDITY)
601 cansolid = true;
602 switch(special)
603 {
604 case spw_clipbottomright:
605 if(dy>=128 || dx>=208) return true;
606 break;
607 case spw_clipright:
608 break; //if(input_x>=208) return true; break;
609
610 case spw_wizzrobe: // fall through
611 case spw_floater: // Special case for fliers and wizzrobes - hack!
612 {
613 if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE))
614 {
615 if(dy < 32-yg || dy >= 144) return true;
616 if(dx < 32 || dx >= 224) return true;
617 }
618 if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb))
619 return true;
620 cansolid = true;
621 flying = true;
622 }
623 }
624
625 dx &= ~7;
626 dy &= ~7;
627
628 if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true;
629
630 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
631 return !(moveflags & FLAG_IGNORE_SCREENEDGE);
632 //_walkflag code
633 mapscr *s1, *s2;
634 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
635 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
636
637 int32_t cpos=(dx>>4)+(dy&0xF0);
638 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
639 newcombo const& c = combobuf[ci];
640 newcombo const& c1 = combobuf[ci1];
641 newcombo const& c2 = combobuf[ci2];
642
643 int32_t b=1;
644 if(dx&8) b<<=2;
645 if(dy&8) b<<=1;
646
647 #define iwtr(cmb, x, y, shallow) \
648 (shallow \
649 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
650 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
651 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
652 bool wtr = iwtr(ci, dx, dy, false);
653 bool shwtr = iwtr(ci, dx, dy, true);
654 bool pit = ispitfall(dx,dy);
655
656 bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb);
657 bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb);
658 bool needwtr = (moveflags & FLAG_ONLY_WATERWALK);
659 bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK);
660 bool needpit = (moveflags & FLAG_ONLY_PITWALK);
661
662 if(!cansolid)
663 {
664 int32_t cwalkflag = c.walk & 0xF;
665 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
666 if (s1)
667 {
668 if (c1.type == cBRIDGE)
669 {
670 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
671 {
672 int efflag = (c1.walk & 0xF0)>>4;
673 int newsolid = (c1.walk & 0xF);
674 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
675 }
676 else cwalkflag &= c1.walk;
677 }
678 else cwalkflag |= c1.walk & 0xF;
679 }
680 if (s2)
681 {
682 if (c2.type == cBRIDGE)
683 {
684 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
685 {
686 int efflag = (c2.walk & 0xF0)>>4;
687 int newsolid = (c2.walk & 0xF);
688 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
689 }
690 else cwalkflag &= c2.walk;
691 }
692 else cwalkflag |= c2.walk & 0xF;
693 }
694 if(cwalkflag & b)
695 return true;
696 }
697 if(needwtr || needshwtr || needpit)
698 {
699 bool ret = true;
700 if (needwtr && wtr) ret = false;
701 else if (needshwtr && shwtr) ret = false;
702 else if (needpit && pit) ret = false;
703 return ret;
704 }
705 else if(wtr && !canwtr)
706 return true;
707 else if(pit && !canpit)
708 return true;
709
710 return false;
711 }
712
713 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
714 {
715 if(!(dx || dy)) return true;
716 zfix bx = x+hxofs, by = y+hyofs; //left/top
717 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
718 if(!ign_sv && dy < 0) //check gravity
719 {
720 if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
721 return false;
722 }
723
724 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
725
726 if(dx && !dy)
727 {
728 if(dx < 0)
729 {
730 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
731 int mx = (bx+dx).getFloor();
732 for(zfix ty = 0; by+ty < ry; ty += 8)
733 {
734 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
735 return false;
736 }
737 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
738 return false;
739 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
740 return false;
741 }
742 else
743 {
744 int mx = (rx+dx).getCeil();
745 int lx = mx-hit_width+1;
746 for(zfix ty = 0; by+ty < ry; ty += 8)
747 {
748 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
749 return false;
750 }
751 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
752 return false;
753 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
754 return false;
755 }
756 }
757 else if(dy && !dx)
758 {
759 if(dy < 0)
760 {
761 special = (special==spw_clipbottomright)?spw_none:special;
762 int my = (by+dy).getFloor();
763 for(zfix tx = 0; bx+tx < rx; tx += 8)
764 {
765 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
766 return false;
767 }
768 if(scr_walkflag(rx, my, special, up, bx, my, kb))
769 return false;
770 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
771 return false;
772 }
773 else
774 {
775 int my = (ry+dy).getCeil();
776 int ly = my-hit_height+1;
777 for(zfix tx = 0; bx+tx < rx; tx += 8)
778 {
779 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
780 return false;
781 }
782 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
783 return false;
784 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
785 return false;
786 }
787 }
788 else //! Untested, and currently unused.
789 {
790 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
791 }
792 return true;
793 }
794
795 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
796 {
797 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
798 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
799
800 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
801
802 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
803 return false;
804 for(zfix ty = 0; by+ty < ry; ty += 8)
805 {
806 for(zfix tx = 0; bx+tx < rx; tx += 8)
807 {
808 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
809 return false;
810 }
811 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
812 return false;
813 }
814 for(zfix tx = 0; bx+tx < rx; tx += 8)
815 {
816 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
817 return false;
818 }
819 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
820 return false;
821 return true;
822 }
823
824 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
825 {
826 auto oxsz = hit_width, oysz = hit_height;
827 if(nwid > -1) hit_width = nwid;
828 if(nhei > -1) hit_height = nhei;
829 bool ret = scr_canplace(dx,dy,special,kb);
830 hit_width = oxsz; hit_height = oysz;
831 return ret;
832 }
833
834 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
835 {
836 bool ret = true;
837 if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
838 dy = 0;
839 const int scl = 2;
840 while(abs(dx) > scl || abs(dy) > scl)
841 {
842 if(abs(dx) > abs(dy))
843 {
844 int32_t tdx = dx.sign() * scl;
845 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
846 dx -= tdx;
847 else
848 {
849 if(earlyret) return false;
850 dx = tdx;
851 ret = false;
852 }
853 }
854 else
855 {
856 int32_t tdy = dy.sign() * scl;
857 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
858 dy -= tdy;
859 else
860 {
861 if(earlyret) return false;
862 dy = tdy;
863 ret = false;
864 }
865 }
866 }
867
868 if(dx)
869 {
870 if(scr_canmove(dx, 0, special, kb, ign_sv))
871 x += dx;
872 else
873 {
874 if(earlyret) return false;
875 ret = false;
876 int xsign = dx.sign();
877 while(scr_canmove(xsign, 0, special, kb, ign_sv))
878 {
879 x += xsign;
880 dx -= xsign;
881 }
882 if(dx)
883 {
884 dx.doDecBound(0,-9999, 0,9999);
885 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
886 if(scr_canmove(val, 0, special, kb, ign_sv))
887 {
888 retval = val;
889 return BSEARCH_CONTINUE_AWAY0;
890 }
891 else return BSEARCH_CONTINUE_TOWARD0;
892 });
893 x += dx;
894 }
895 }
896 }
897 if(dy)
898 {
899 if(scr_canmove(0, dy, special, kb, ign_sv))
900 y += dy;
901 else
902 {
903 if(earlyret) return false;
904 ret = false;
905 int ysign = dy.sign();
906 while(scr_canmove(0, ysign, special, kb, ign_sv))
907 {
908 y += ysign;
909 dy -= ysign;
910 }
911 if(dy)
912 {
913 dy.doDecBound(0,-9999, 0,9999);
914 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
915 if(scr_canmove(0, val, special, kb, ign_sv))
916 {
917 retval = val;
918 return BSEARCH_CONTINUE_AWAY0;
919 }
920 else return BSEARCH_CONTINUE_TOWARD0;
921 });
922 y += dy;
923 }
924 }
925 }
926 return ret;
927 }
928
929 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
930 {
931 static const zfix diagrate = zslongToFix(7071);
932 switch(NORMAL_DIR(dir))
933 {
934 case up:
935 return movexy(0, -px, special, kb, false, earlyret);
936 case down:
937 return movexy(0, px, special, kb, false, earlyret);
938 case left:
939 return movexy(-px, 0, special, kb, false, earlyret);
940 case right:
941 return movexy(px, 0, special, kb, false, earlyret);
942 case r_up:
943 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
944 case r_down:
945 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
946 case l_up:
947 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
948 case l_down:
949 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
950 }
951 return false;
952 }
953
954 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
955 {
956 double v = degrees.getFloat() * PI / 180.0;
957 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
958 return movexy(dx, dy, special, kb, false, earlyret);
959 }
960
961 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
962 {
963 zfix tx = x, ty = y;
964 bool ret = movexy(dx, dy, special, kb, false, true);
965 x = tx;
966 y = ty;
967 return ret;
968 }
969 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
970 {
971 zfix tx = x, ty = y;
972 bool ret = moveDir(dir, px, special, kb, true);
973 x = tx;
974 y = ty;
975 return ret;
976 }
977 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
978 {
979 zfix tx = x, ty = y;
980 bool ret = moveAtAngle(degrees, px, special, kb, true);
981 x = tx;
982 y = ty;
983 return ret;
984 }
985
986 // Handle pitfalls
987 21148762 bool enemy::do_falling(int32_t index)
988 {
989
2/2
✓ Branch 0 taken 21148620 times.
✓ Branch 1 taken 142 times.
21148762 if(fallclk > 0)
990 {
991
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
142 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
992
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 4 times.
142 if(!--fallclk)
993 {
994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(immortal) //Keep alive forever
995 ++fallclk; //force another frame of falling.... forever.
996
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(dying) //Give 1 frame for script revival
997 {
998
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags&guy_neverret)
999 never_return(index);
1000
1001
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(leader)
1002 kill_em_all();
1003
1004 //leave_item(); //Don't drop items in pits!
1005 2 stop_bgsfx(index);
1006 2 return true;
1007 }
1008 else
1009 {
1010 2 try_death(true); //Force death
1011 2 ++fallclk; //force another frame of falling
1012 }
1013 2 }
1014
1015 140 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1016 140 cs = spr.csets & 0xF;
1017
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t fr = spr.frames ? spr.frames : 1;
1018
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t spd = spr.speed ? spr.speed : 1;
1019 140 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1020
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
140 tile = spr.tile + zc_min(animclk / spd, fr-1);
1021 140 }
1022 21148760 return false;
1023 21148762 }
1024
1025 // Handle drowning in water
1026 21148620 bool enemy::do_drowning(int32_t index)
1027 {
1028
1/2
✓ Branch 0 taken 21148620 times.
✗ Branch 1 not taken.
21148620 if(drownclk > 0)
1029 {
1030 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1031 //!TODO: Drown SFX
1032 if(!--drownclk)
1033 {
1034 if(immortal) //Keep alive forever
1035 ++drownclk; //force another frame of falling.... forever.
1036 else if(dying) //Give 1 frame for script revival
1037 {
1038 if(flags&guy_neverret)
1039 never_return(index);
1040
1041 if(leader)
1042 kill_em_all();
1043
1044 //leave_item(); //Don't drop items in pits!
1045 stop_bgsfx(index);
1046 return true;
1047 }
1048 else
1049 {
1050 try_death(true); //Force death
1051 ++drownclk; //force another frame of falling
1052 }
1053 }
1054
1055 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
1056 {
1057 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
1058 cs = spr.csets & 0xF;
1059 int32_t fr = spr.frames ? spr.frames : 1;
1060 int32_t spd = spr.speed ? spr.speed : 1;
1061 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1062 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1063 }
1064 else
1065 {
1066 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
1067 cs = spr.csets & 0xF;
1068 int32_t fr = spr.frames ? spr.frames : 1;
1069 int32_t spd = spr.speed ? spr.speed : 1;
1070 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1071 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1072 }
1073 }
1074 21148620 return false;
1075 21148620 }
1076
1077 // Supplemental animation code that all derived classes should call
1078 // as a return value for animate().
1079 // Handles the death animation and returns true when enemy is finished.
1080 21532885 bool enemy::Dead(int32_t index)
1081 {
1082
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 21531056 times.
21532885 if(immortal)
1083 {
1084 1829 dying = false;
1085 1829 return false;
1086 }
1087
2/2
✓ Branch 0 taken 449834 times.
✓ Branch 1 taken 21081222 times.
21531056 if(dying)
1088 {
1089
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 449833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
449834 if(deathexstate > -1 && deathexstate < 32)
1090 {
1091 1 setxmapflag(1<<deathexstate);
1092 1 deathexstate = -1;
1093 1 }
1094 449834 --clk2;
1095
1096
4/4
✓ Branch 0 taken 445139 times.
✓ Branch 1 taken 4695 times.
✓ Branch 2 taken 21421 times.
✓ Branch 3 taken 2961 times.
449834 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1097
2/2
✓ Branch 0 taken 24382 times.
✓ Branch 1 taken 420757 times.
445139 && hp>-1000) // not killed by ringleader
1098 21421 death_sfx();
1099
1100
2/2
✓ Branch 0 taken 425254 times.
✓ Branch 1 taken 24580 times.
449834 if(clk2==0)
1101 {
1102
2/2
✓ Branch 0 taken 24174 times.
✓ Branch 1 taken 406 times.
24580 if(flags&guy_neverret)
1103 406 never_return(index);
1104
1105
2/2
✓ Branch 0 taken 24523 times.
✓ Branch 1 taken 57 times.
24580 if(leader)
1106 57 kill_em_all();
1107
1108 24580 leave_item();
1109 24580 }
1110
1111 449834 stop_bgsfx(index);
1112 449834 return (clk2==0);
1113 }
1114
1115 21081222 return false;
1116 21532885 }
1117
1118 // Basic animation code that all derived classes should call.
1119 // The one with an index is the one that is called by
1120 // the guys sprite list; index is the enemy's index in the list.
1121 21148762 bool enemy::animate(int32_t index)
1122 {
1123
2/2
✓ Branch 0 taken 896465 times.
✓ Branch 1 taken 20252297 times.
21148762 if(sclk <= 0) hitdir = -1;
1124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148762 times.
21148762 if(switch_hooked)
1125 {
1126 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1127 {
1128 //Run its script
1129 if (!didScriptThisFrame)
1130 {
1131 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1132 {
1133 return 0; //Avoid NULLPO if this object deleted itself
1134 }
1135 }
1136 }
1137 return false;
1138 }
1139
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21148760 times.
21148762 if(do_falling(index)) return true;
1140
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 21148620 times.
21148760 else if(fallclk)
1141 {
1142 //clks
1143
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
140 if(hclk>0)
1144 60 --hclk;
1145
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(stunclk>0)
1146 --stunclk;
1147
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( frozenclock > 0 )
1148 --frozenclock;
1149
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(hashero)
1150 {
1151 Hero.setX(x);
1152 Hero.setY(y);
1153 Hero.fallCombo = fallCombo;
1154 Hero.fallclk = fallclk;
1155 hashero = false; //Let Hero go if falling
1156 }
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!didScriptThisFrame)
1158 {
1159 140 run_script(MODE_NORMAL);
1160 140 }
1161 140 return false;
1162 }
1163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if(do_drowning(index)) return true;
1164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 else if(drownclk)
1165 {
1166 //clks
1167 if(hclk>0)
1168 --hclk;
1169 if(stunclk>0)
1170 --stunclk;
1171 if ( frozenclock > 0 )
1172 --frozenclock;
1173 if(hashero)
1174 {
1175 Hero.setX(x);
1176 Hero.setY(y);
1177 Hero.drownclk = drownclk;
1178 hashero = false; //Let Hero go if falling
1179 }
1180 if (!didScriptThisFrame)
1181 {
1182 run_script(MODE_NORMAL);
1183 }
1184 return false;
1185 }
1186 21148620 int32_t nx = real_x(x);
1187 21148620 int32_t ny = real_y(y);
1188
1189
4/4
✓ Branch 0 taken 15590435 times.
✓ Branch 1 taken 5558185 times.
✓ Branch 2 taken 3126427 times.
✓ Branch 3 taken 12464008 times.
21148620 if(ox!=nx || oy!=ny)
1190 {
1191 8684612 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1192 8684612 }
1193
1194 21148620 ox = nx;
1195 21148620 oy = ny;
1196
1197 // Maybe they fell off the bottom in sideview, or were moved by a script.
1198
1199 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1200
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 21146791 times.
21148620 if ( immortal )
1201 {
1202 //skip, as it can go out of bounds, from immortality
1203 1829 }
1204
2/6
✓ Branch 0 taken 21146791 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21146791 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21146791 else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1205 {
1206 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1207 }
1208
9/10
✓ Branch 0 taken 20750698 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 21145786 times.
✓ Branch 3 taken 1005 times.
✓ Branch 4 taken 21116075 times.
✓ Branch 5 taken 29711 times.
✓ Branch 6 taken 21116075 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 21116039 times.
21146791 else if ( (OUTOFBOUNDS) )
1209 {
1210 30752 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1211 30752 }
1212 //fall down
1213
6/6
✓ Branch 0 taken 13962695 times.
✓ Branch 1 taken 7185925 times.
✓ Branch 2 taken 7026915 times.
✓ Branch 3 taken 14121705 times.
✓ Branch 4 taken 338067 times.
✓ Branch 5 taken 6688848 times.
21148620 if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0)
1214 {
1215
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 6385274 times.
6688848 if(isSideViewGravity())
1216 {
1217
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1218 {
1219
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
1220 {
1221 127235 bool willHitSVPlatform = false;
1222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hit_width:16;
1223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hit_height:16;
1224
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1225 {
1226
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1227 {
1228 willHitSVPlatform = true;
1229 break;
1230 }
1231 127235 }
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
1233 {
1234 y+=fall/100;
1235 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1236 do_fix(y, 16); //Fix to top of SV Ladder
1237 fall = 0;
1238 }
1239 else
1240 {
1241 127235 y+=fall/100;
1242
2/2
✓ Branch 0 taken 109427 times.
✓ Branch 1 taken 17808 times.
127235 if(fall <= (int32_t)zinit.terminalv)
1243 109427 fall += (zinit.gravity/100);
1244 }
1245 127235 }
1246 else
1247 {
1248
2/2
✓ Branch 0 taken 176072 times.
✓ Branch 1 taken 267 times.
176339 if(fall!=0) // Only fix pos once
1249 {
1250 //y-=(int32_t)y%8; // Fix position
1251 267 do_fix(y, 8); //Fix position
1252 267 }
1253
1254 176339 fall = 0;
1255 }
1256 303574 }
1257 else
1258 {
1259 if(isOnSideviewPlatform())
1260 fall = 0;
1261 else
1262 {
1263 zfix fall_amnt = fall/100;
1264 bool hit = false;
1265 while(fall_amnt >= 1)
1266 {
1267 --fall_amnt;
1268 ++y;
1269 if(isOnSideviewPlatform())
1270 {
1271 y = y.getInt();
1272 fall_amnt = 0;
1273 hit = true;
1274 break;
1275 }
1276 }
1277 if(fall_amnt > 0)
1278 y += fall_amnt;
1279 if(fall_amnt < 0)
1280 {
1281 if(!movexy(0,fall_amnt,spw_none))
1282 hit = true;
1283 }
1284 if(hit)
1285 fall = 0;
1286 else if(fall <= (int32_t)zinit.terminalv)
1287 fall += (zinit.gravity/100);
1288 }
1289 }
1290 303574 }
1291 else
1292 {
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6385274 times.
6385274 if (!(moveflags & FLAG_NO_FAKE_Z))
1294 {
1295
2/2
✓ Branch 0 taken 3220250 times.
✓ Branch 1 taken 3165024 times.
6385274 if(fakefall!=0)
1296 3165024 fakez-=(fakefall/100);
1297
1298
2/2
✓ Branch 0 taken 3165024 times.
✓ Branch 1 taken 3220250 times.
6385274 if(fakez<0)
1299 3165024 fakez = fakefall = 0;
1300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3220250 times.
3220250 else if(fakefall <= (int32_t)zinit.terminalv)
1301 3220250 fakefall += (zinit.gravity/100);
1302
1303
5/6
✓ Branch 0 taken 6385274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3220250 times.
✓ Branch 3 taken 3165024 times.
✓ Branch 4 taken 3173265 times.
✓ Branch 5 taken 46985 times.
6385274 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1304 6385274 }
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6385274 times.
6385274 if (!(moveflags & FLAG_NO_REAL_Z))
1306 {
1307
2/2
✓ Branch 0 taken 3486762 times.
✓ Branch 1 taken 2898512 times.
6385274 if(fall!=0)
1308 2898512 z-=(fall/100);
1309
1310
2/2
✓ Branch 0 taken 2892688 times.
✓ Branch 1 taken 3492586 times.
6385274 if(z<0)
1311 2892688 z = fall = 0;
1312
2/2
✓ Branch 0 taken 4644 times.
✓ Branch 1 taken 3487942 times.
3492586 else if(fall <= (int32_t)zinit.terminalv)
1313 3487942 fall += (zinit.gravity/100);
1314
1315
6/6
✓ Branch 0 taken 6379353 times.
✓ Branch 1 taken 5921 times.
✓ Branch 2 taken 3486665 times.
✓ Branch 3 taken 2892688 times.
✓ Branch 4 taken 3439680 times.
✓ Branch 5 taken 46985 times.
6385274 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1316 6385274 }
1317
1318 }
1319 6688848 }
1320
4/4
✓ Branch 0 taken 20752527 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 5819008 times.
✓ Branch 3 taken 18007049 times.
21148620 if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL))
1321 {
1322
8/10
✓ Branch 0 taken 6010270 times.
✓ Branch 1 taken 11996779 times.
✓ Branch 2 taken 6003285 times.
✓ Branch 3 taken 6985 times.
✓ Branch 4 taken 6003285 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6010270 times.
✓ Branch 8 taken 6003285 times.
✓ Branch 9 taken 6003285 times.
18007049 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1323 {
1324 6003285 fallCombo = check_pits();
1325 6003285 }
1326 30013619 }
1327
3/4
✓ Branch 0 taken 20752527 times.
✓ Branch 1 taken 8638509 times.
✓ Branch 2 taken 20752527 times.
✗ Branch 3 not taken.
12235162 if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN))
1328 {
1329 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1330 {
1331 drownCombo = check_water();
1332 }
1333 }
1334
1335 29391036 runKnockback(); //scripted knockback handling
1336
1337 // clk is incremented here
1338
2/2
✓ Branch 0 taken 28255119 times.
✓ Branch 1 taken 1135917 times.
29391036 if(++clk >= frate)
1339 1135917 clk=0;
1340
1341 // hit and death handling
1342
2/2
✓ Branch 0 taken 28707305 times.
✓ Branch 1 taken 683731 times.
29391036 if(hclk>0)
1343 683731 --hclk;
1344
1345
2/2
✓ Branch 0 taken 28958644 times.
✓ Branch 1 taken 432392 times.
29391036 if(stunclk>0)
1346 432392 --stunclk;
1347
1/2
✓ Branch 0 taken 29391036 times.
✗ Branch 1 not taken.
29391036 if ( frozenclock > 0 )
1348 --frozenclock;
1349
1350
5/6
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 29384034 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 6947 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
29391036 if(ceiling && z <= 0 && fakez <= 0)
1351 55 ceiling = false;
1352
1353 29391036 try_death();
1354
1355 29391036 scored=false;
1356
1357 29391036 ++c_clk;
1358
1359 //Run its script
1360
2/2
✓ Branch 0 taken 8242416 times.
✓ Branch 1 taken 21148620 times.
29391036 if (!didScriptThisFrame)
1361 {
1362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1363 {
1364 return 0; //Avoid NULLPO if this object deleted itself
1365 }
1366 21148620 }
1367
1368 // returns true when enemy is defeated
1369 29391036 return Dead(index);
1370 29391178 }
1371
1372 21572753 bool enemy::setSolid(bool set)
1373 {
1374
1/2
✓ Branch 0 taken 21572753 times.
✗ Branch 1 not taken.
21572753 bool actual = set && !isSubmerged();
1375 21572753 bool ret = solid_object::setSolid(actual);
1376 21572753 solid = set;
1377 21572753 return ret;
1378 }
1379 void enemy::doContactDamage(int32_t hdir)
1380 {
1381 Hero.hithero(guys.find(this), hdir);
1382 }
1383
1384 3278 void enemy::solid_push(solid_object *obj)
1385 {
1386
1/2
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
3278 if(obj == this) return; //can't push self
1387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
3278 if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable
1388 3278 zfix dx, dy;
1389 3278 int32_t hdir = -1;
1390 3278 solid_push_int(obj,dx,dy,hdir,true);
1391
1392
2/4
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3278 times.
✗ Branch 3 not taken.
3278 if(!dx && !dy) return;
1393
1394 bool t = obj->getTempNonsolid();
1395 obj->setTempNonsolid(true);
1396
1397 int32_t ydir = dy > 0 ? down : up;
1398 int32_t xdir = dx > 0 ? right : left;
1399
1400 auto special = isflier(id) ? spw_floater : spw_none;
1401 if(!movexy(dx,dy,special,true,true))
1402 {
1403 //Crushed?
1404 }
1405
1406 obj->setTempNonsolid(t);
1407 3278 }
1408 3278 bool enemy::is_unpushable() const
1409 {
1410 3278 return isSubmerged();
1411 }
1412 3278 bool enemy::sideview_mode() const
1413 {
1414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3278 return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE);
1415 }
1416
1417 2559 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1418 {
1419 2559 int32_t yg = (special==spw_floater)?8:0;
1420 2559 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1421
1422
8/10
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 613 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 613 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 613 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1948 times.
✓ Branch 9 taken 2561 times.
2559 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1423 3894 return true;
1424
1425 2561 bool isInDungeon = isdungeon();
1426
3/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 2445 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
2561 if(isInDungeon || special==spw_wizzrobe)
1427 {
1428
7/8
✓ Branch 0 taken 494 times.
✓ Branch 1 taken 1951 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 495 times.
✓ Branch 5 taken 1462 times.
✓ Branch 6 taken 495 times.
✗ Branch 7 not taken.
2445 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1429 983 return true;
1430
1431
7/8
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 488 times.
✓ Branch 5 taken 488 times.
✓ Branch 6 taken 488 times.
✗ Branch 7 not taken.
1462 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1432
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
976 if(special!=spw_door) // walk in door way
1433 return true;
1434 488 }
1435
1436
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
604 if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func)
1437 {
1438
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1439
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1440 return true;
1441 62 }
1442
1443
1/4
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
604 switch(special)
1444 {
1445 case spw_clipbottomright:
1446 if(dy>=128 || dx>=208) return true;
1447 break;
1448 case spw_clipright:
1449 break; //if(x>=208) return true; break;
1450
1451 case spw_wizzrobe: // fall through
1452 case spw_floater: // Special case for fliers and wizzrobes - hack!
1453 {
1454
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 488 times.
604 if(isInDungeon)
1455 {
1456
2/4
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
488 if(dy < 32-yg || dy >= 144) return true;
1457
2/4
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
488 if(dx < 32 || dx >= 224) return true;
1458 488 }
1459 604 return false;
1460 }
1461 }
1462
1463 dx&=(special==spw_halfstep)?(~7):(~15);
1464 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1465
1466 if(special==spw_water)
1467 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1468
1469 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1470 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1471 613 }
1472
1473 5149 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1474 {
1475 5149 bool kb = false;
1476 5149 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1477
1478
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5149 times.
✓ Branch 2 taken 5149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5149 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5149 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 5149 times.
5149 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
1479 return true;
1480
1481
2/2
✓ Branch 0 taken 4434 times.
✓ Branch 1 taken 715 times.
5149 if(isdungeon())
1482 {
1483
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dy<32) || (dy>=144))
1484 return true;
1485
1486
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dx<32) || (dx>=224))
1487 return true;
1488 715 }
1489
1490
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
5149 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back
1491 {
1492
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
10298 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1493
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5149 times.
✗ Branch 3 not taken.
5149 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1494 return true;
1495 5149 }
1496
1497
1/2
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
5149 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1498 {
1499
3/4
✓ Branch 0 taken 1489 times.
✓ Branch 1 taken 3660 times.
✓ Branch 2 taken 1489 times.
✗ Branch 3 not taken.
6638 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1489 times.
1489 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1501 }
1502 else
1503 {
1504 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1505 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1506 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1507 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1508 }
1509 5149 }
1510
1511 19029446 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1512 {
1513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19029446 times.
19029446 if(moveflags & FLAG_USE_NEW_MOVEMENT)
1514 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1515 19029446 int32_t yg = (special==spw_floater)?8:0;
1516 19029446 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1517
2/2
✓ Branch 0 taken 1960677 times.
✓ Branch 1 taken 17068769 times.
19029446 switch(dir)
1518 {
1519 case l_down:
1520 case r_down:
1521 case down:
1522 case 11: //r_down
1523 case 12: //down
1524 case 13: //l_down
1525 {
1526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1960677 times.
1960677 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1527 {
1528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1960677 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1960677 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
1529 {
1530 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1531 dy += zc_max(hit_height-16,0);
1532 }
1533 1960677 }
1534 1960677 break;
1535 }
1536 }
1537
2/2
✓ Branch 0 taken 1972909 times.
✓ Branch 1 taken 17056537 times.
19029446 switch(dir)
1538 {
1539 case r_up:
1540 case r_down:
1541 case right:
1542 case 9: //r_up
1543 case 10: //right
1544 case 11: //r_down
1545 {
1546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1972909 times.
1972909 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1547 {
1548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1972909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1972909 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
1549 {
1550 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1551 dx += zc_max(hit_width-16,0);
1552 }
1553 1972909 }
1554 1972909 break;
1555 }
1556 }
1557 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1558
1559
10/10
✓ Branch 0 taken 13730315 times.
✓ Branch 1 taken 5299131 times.
✓ Branch 2 taken 4431976 times.
✓ Branch 3 taken 867155 times.
✓ Branch 4 taken 5287042 times.
✓ Branch 5 taken 12089 times.
✓ Branch 6 taken 5274023 times.
✓ Branch 7 taken 13019 times.
✓ Branch 8 taken 13757809 times.
✓ Branch 9 taken 19031832 times.
19029446 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1560 27513232 return true;
1561
1562 19031832 bool isInDungeon = isdungeon();
1563
4/4
✓ Branch 0 taken 1581593 times.
✓ Branch 1 taken 17450239 times.
✓ Branch 2 taken 1123 times.
✓ Branch 3 taken 1580470 times.
19031832 if(isInDungeon || special==spw_wizzrobe)
1564 {
1565
8/8
✓ Branch 0 taken 3601717 times.
✓ Branch 1 taken 13849645 times.
✓ Branch 2 taken 3471583 times.
✓ Branch 3 taken 130134 times.
✓ Branch 4 taken 3560656 times.
✓ Branch 5 taken 10419123 times.
✓ Branch 6 taken 3560642 times.
✓ Branch 7 taken 14 times.
17451362 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
1566 7032225 return true;
1567
1568
8/8
✓ Branch 0 taken 3512677 times.
✓ Branch 1 taken 6906460 times.
✓ Branch 2 taken 3413625 times.
✓ Branch 3 taken 99052 times.
✓ Branch 4 taken 3480646 times.
✓ Branch 5 taken 3524866 times.
✓ Branch 6 taken 3480643 times.
✓ Branch 7 taken 3 times.
10419137 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
1569
2/2
✓ Branch 0 taken 66979 times.
✓ Branch 1 taken 39 times.
6894268 if(special!=spw_door) // walk in door way
1570 66979 return true;
1571 3524908 }
1572
1573
6/6
✓ Branch 0 taken 2212798 times.
✓ Branch 1 taken 2892580 times.
✓ Branch 2 taken 427580 times.
✓ Branch 3 taken 1785218 times.
✓ Branch 4 taken 34289 times.
✓ Branch 5 taken 393291 times.
5105378 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
1574 {
1575
3/4
✓ Branch 0 taken 2178502 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2178502 times.
4357011 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1576
2/4
✓ Branch 0 taken 2178502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2178502 times.
✗ Branch 3 not taken.
2178502 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1577 7 return true;
1578 2178502 }
1579
1580
4/4
✓ Branch 0 taken 4093655 times.
✓ Branch 1 taken 1008118 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 3553 times.
5105371 switch(special)
1581 {
1582 case spw_clipbottomright:
1583
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if(dy>=128 || dx>=208) return true;
1584 45 break;
1585 case spw_clipright:
1586 3553 break; //if(input_x>=208) return true; break;
1587
1588 case spw_wizzrobe: // fall through
1589 case spw_floater: // Special case for fliers and wizzrobes - hack!
1590 {
1591
2/2
✓ Branch 0 taken 1101316 times.
✓ Branch 1 taken 2992339 times.
4093655 if(isInDungeon)
1592 {
1593
3/4
✓ Branch 0 taken 2992328 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2992328 times.
2992339 if(dy < 32-yg || dy >= 144) return true;
1594
3/4
✓ Branch 0 taken 2991477 times.
✓ Branch 1 taken 851 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2991477 times.
2992328 if(dx < 32 || dx >= 224) return true;
1595 2991477 }
1596 4092793 return false;
1597 }
1598 }
1599
1600 1011716 dx&=(special==spw_halfstep)?(~7):(~15);
1601
2/2
✓ Branch 0 taken 224029 times.
✓ Branch 1 taken 787687 times.
1011716 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1602
1603
2/2
✓ Branch 0 taken 117322 times.
✓ Branch 1 taken 894394 times.
1011716 if(special==spw_water)
1604
2/2
✓ Branch 0 taken 8245 times.
✓ Branch 1 taken 109077 times.
117322 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1605
1606
2/2
✓ Branch 0 taken 892220 times.
✓ Branch 1 taken 2174 times.
894394 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1607 {
1608
4/4
✓ Branch 0 taken 666298 times.
✓ Branch 1 taken 225922 times.
✓ Branch 2 taken 660380 times.
✓ Branch 3 taken 5918 times.
1552600 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1609
2/2
✓ Branch 0 taken 2852 times.
✓ Branch 1 taken 657528 times.
660380 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1610 }
1611 else
1612 {
1613
4/4
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 555 times.
✓ Branch 2 taken 1607 times.
✓ Branch 3 taken 12 times.
3781 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1614
3/4
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1599 times.
✗ Branch 3 not taken.
1607 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1615
3/4
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 1565 times.
✗ Branch 3 not taken.
1599 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1565 times.
1565 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1617 }
1618 5314018 }
1619
1620 383430 bool enemy::isOnSideviewPlatform()
1621 {
1622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
1623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1624
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
1625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
1626
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1627 {
1628
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
1629
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1631 47357 }
1632 168001 return false;
1633 383430 }
1634
1635 // Stops playing the given sound only if there are no enemies left to play it
1636 451658 void enemy::stop_bgsfx(int32_t index)
1637 {
1638
2/2
✓ Branch 0 taken 441954 times.
✓ Branch 1 taken 9704 times.
451658 if(bgsfx<=0)
1639 441954 return;
1640
1641 // Look for other enemies with the same bgsfx
1642
2/2
✓ Branch 0 taken 39307 times.
✓ Branch 1 taken 5718 times.
45025 for(int32_t i=0; i<guys.Count(); i++)
1643 {
1644
4/4
✓ Branch 0 taken 32357 times.
✓ Branch 1 taken 6950 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 28371 times.
39307 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1645 3986 return;
1646 35321 }
1647
1648 5718 stop_sfx(bgsfx);
1649 451658 }
1650
1651
1652 // to allow for different sfx on defeating enemy
1653 21658 void enemy::death_sfx()
1654 {
1655
2/2
✓ Branch 0 taken 21634 times.
✓ Branch 1 taken 24 times.
21658 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1656 21658 }
1657
1658 void enemy::move(zfix dx,zfix dy)
1659 {
1660 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1661 {
1662 switch(family)
1663 {
1664 case eeFIRE:
1665 case eeOTHER:
1666 return;
1667 default: break;
1668 }
1669 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1670 }
1671 */
1672 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id)))
1673 {
1674 x+=dx;
1675 y+=dy;
1676 }
1677 }
1678
1679 10385398 void enemy::move(zfix s)
1680 {
1681 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1682 {
1683 switch(family)
1684 {
1685 case eeFIRE:
1686 case eeOTHER:
1687 return;
1688 default: break;
1689 }
1690 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1691 }*/
1692
9/10
✓ Branch 0 taken 10385359 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 10305597 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
10385398 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV)))
1693 {
1694 10384504 sprite::move(s);
1695 10384504 }
1696 10385398 }
1697
1698 24760 void enemy::leave_item()
1699 {
1700 24760 int32_t drop_item = select_dropitem(item_set, x, y);
1701 24760 int32_t thedropset = item_set;
1702
1703 24760 std::vector<int32_t> &ev = FFCore.eventData;
1704 24760 ev.clear();
1705 24760 ev.push_back(getUID());
1706 24760 ev.push_back(drop_item*10000);
1707 24760 ev.push_back(thedropset*10000);
1708
1709 24760 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1710 24760 drop_item = vbound(ev[1] / 10000,-2,255);
1711 24760 thedropset = ev[2] / 10000;
1712 24760 ev.clear();
1713
1/2
✓ Branch 0 taken 24760 times.
✗ Branch 1 not taken.
24760 if(drop_item == -2)
1714 {
1715 drop_item = select_dropitem(thedropset,x,y);
1716 }
1717
1718
6/6
✓ Branch 0 taken 9759 times.
✓ Branch 1 taken 15001 times.
✓ Branch 2 taken 563 times.
✓ Branch 3 taken 9196 times.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 414 times.
24760 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1719 {
1720 item* itm;
1721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9610 times.
9610 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1722 {
1723 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1724 }
1725 else
1726 {
1727
8/14
✓ Branch 0 taken 1436 times.
✓ Branch 1 taken 8174 times.
✓ Branch 2 taken 1436 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1436 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1436 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1436 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1436 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1436 times.
✗ Branch 13 not taken.
9610 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1728
4/8
✓ Branch 0 taken 8174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8174 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8174 times.
✗ Branch 7 not taken.
8174 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1729 }
1730 9610 itm->from_dropset = thedropset;
1731 9610 items.add(itm);
1732
1733 9610 ev.push_back(getUID());
1734 9610 ev.push_back(itm->getUID());
1735
1736 9610 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1737 9610 ev.clear();
1738 9610 }
1739 24760 }
1740
1741 // auomatically kill off enemy (for rooms with ringleaders)
1742 344 void enemy::kickbucket()
1743 {
1744
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 32 times.
344 if(!superman)
1745 312 hp=-1000; // don't call death_sfx()
1746 344 }
1747
1748 3278 bool enemy::isSubmerged() const
1749 {
1750 3278 return submerged;
1751 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1752 }
1753
1754 17408 void enemy::FireBreath(bool seekhero)
1755 {
1756
1/2
✓ Branch 0 taken 17408 times.
✗ Branch 1 not taken.
17408 if(wpn==wNone)
1757 return;
1758
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17408 times.
17408 if(wpn==ewFireTrail)
1760 {
1761 dmisc1 = e1tEACHTILE;
1762 FireWeapon();
1763 return;
1764 }
1765
1766 17408 float fire_angle=0.0;
1767 17408 int32_t wx=0, wy=0, wdir=dir;
1768
1769
2/2
✓ Branch 0 taken 1704 times.
✓ Branch 1 taken 15704 times.
17408 if(!seekhero)
1770 {
1771
4/5
✓ Branch 0 taken 3271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3038 times.
✓ Branch 3 taken 5264 times.
✓ Branch 4 taken 4131 times.
15704 switch(dir)
1772 {
1773 case down:
1774 3038 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1775 3038 wx=x;
1776 3038 wy=y+8;
1777 3038 break;
1778
1779 case -1:
1780 case up:
1781 3271 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1782 3271 wx=x;
1783 3271 wy=y-8;
1784 3271 break;
1785
1786 case left:
1787 5264 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1788 5264 wx=x-8;
1789 5264 wy=y;
1790 5264 break;
1791
1792 case right:
1793 4131 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1794 4131 wx=x+8;
1795 4131 wy=y;
1796 4131 break;
1797 }
1798
1799
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15704 if(wpn==ewFlame || wpn==ewFlame2)
1800 {
1801
2/4
✓ Branch 0 taken 15704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15704 times.
15704 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==-PI/2) wdir=up;
1803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==PI/2) wdir=down;
1804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==0) wdir=right;
1805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<-PI/2) wdir=l_up;
1806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<0) wdir=r_up;
1807
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14206 times.
15704 else if(fire_angle<(PI/2)) wdir=r_down;
1808
2/2
✓ Branch 0 taken 10090 times.
✓ Branch 1 taken 4116 times.
14206 else if(fire_angle<PI) wdir=l_down;
1809 15704 }
1810 15704 }
1811 else
1812 {
1813 1704 wx = x;
1814 1704 wy = y;
1815 }
1816
1817
2/2
✓ Branch 0 taken 1704 times.
✓ Branch 1 taken 15704 times.
17408 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1818 17408 sfx(wpnsfx(wpn),pan(int32_t(x)));
1819
1820 17408 int32_t i=Ewpns.Count()-1;
1821 17408 weapon *ew = (weapon*)(Ewpns.spr(i));
1822 17408 ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1823
1824
4/4
✓ Branch 0 taken 15704 times.
✓ Branch 1 taken 1704 times.
✓ Branch 2 taken 7830 times.
✓ Branch 3 taken 7874 times.
17408 if(!seekhero && (zc_oldrand()&4))
1825 {
1826 7874 ew->angular=true;
1827 7874 ew->angle=fire_angle;
1828 7874 }
1829
1830
4/4
✓ Branch 0 taken 17351 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 17034 times.
17408 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1831 {
1832 17034 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17034 times.
17034 if ( ew->do_animation ) ew->tile+=ew->aframe;
1834 17034 }
1835
1836
2/2
✓ Branch 0 taken 17408 times.
✓ Branch 1 taken 543348 times.
560756 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1837 {
1838 543348 Ewpns.swap(j,j-1);
1839 543348 }
1840 17408 }
1841
1842 28308 void enemy::FireWeapon()
1843 {
1844 /*
1845 * Type:
1846 * 0x01: Boss fireball
1847 * 0x02: Seeks Hero
1848 * 0x04: Fast projectile
1849 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1850 */
1851
1852
2/2
✓ Branch 0 taken 28298 times.
✓ Branch 1 taken 10 times.
28308 if (wpn < 1) return;
1853
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 28298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
28298 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1854 return;
1855
1856
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28298 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1857 dmisc1 = e1tEACHTILE;
1858
1859 28298 int32_t xoff = 0;
1860 28298 int32_t yoff = 0;
1861
1/2
✓ Branch 0 taken 28298 times.
✗ Branch 1 not taken.
28298 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
1862 {
1863 xoff += (hit_width/2)-8;
1864 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
1865 }
1866
1/2
✓ Branch 0 taken 28298 times.
✗ Branch 1 not taken.
28298 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
1867 {
1868 yoff += (hit_height/2)-8;
1869 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
1870 }
1871
1872
4/8
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 26887 times.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28298 switch(dmisc1)
1873 {
1874 case e1t5SHOTS: //BS-Aquamentus
1875 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1876 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1877 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1878 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1879
1880 [[fallthrough]];
1881 case e1t3SHOTSFAST:
1882 case e1t3SHOTS: //Aquamentus
1883
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1884 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1885
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1886 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1887
1888 [[fallthrough]];
1889 default:
1890
11/20
✓ Branch 0 taken 27300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 27300 times.
✓ Branch 12 taken 27300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 11345 times.
✓ Branch 15 taken 15955 times.
✓ Branch 16 taken 27300 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 27300 times.
✗ Branch 19 not taken.
27300 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1891 27300 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1892 27300 sfx(wpnsfx(wpn),pan(int32_t(x)));
1893 27300 break;
1894
1895 case e1tSLANT:
1896 {
1897 409 int32_t slant = 0;
1898
1899
10/10
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 304 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 173 times.
409 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1900 236 slant = left;
1901
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 29 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 85 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 61 times.
173 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1902 112 slant = right;
1903
1904
9/18
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 319 times.
✓ Branch 14 taken 319 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 319 times.
✗ Branch 17 not taken.
319 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1905 319 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1906 319 sfx(wpnsfx(wpn),pan(int32_t(x)));
1907 319 break;
1908 }
1909
1910 case e1t8SHOTS: //Fire Wizzrobe
1911 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1912 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1913 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1914 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1915 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1916 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1917 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1918 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1919 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1920 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1921 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1922 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1923
1924 [[fallthrough]];
1925 case e1t4SHOTS: //Stalfos 3
1926
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1927 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1928 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1929
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1930 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1931 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1932
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1933 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1934 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1935
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1936 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1937 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1938 589 sfx(wpnsfx(wpn),pan(int32_t(x)));
1939 589 break;
1940
1941 case e1tSUMMON: // Bat Wizzrobe
1942 {
1943 //al_trace("Summon Bats\n");
1944 //zprint2("Summon Bats\n");
1945 if(dmisc4==0) break; // Summon 0
1946
1947 int32_t bc=0;
1948
1949 for(int32_t gc=0; gc<guys.Count(); gc++)
1950 {
1951 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1952 {
1953 ++bc;
1954 }
1955 }
1956
1957 if(bc<=40) // Not too many enemies
1958 {
1959 int32_t kids = guys.Count();
1960 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1961
1962 for(int32_t i=0; i<bats; i++)
1963 {
1964 //zprint2("summon\n");
1965 //al_trace("summon\n");
1966 if(addchild(x,y,dmisc3,-10, this->script_UID))
1967 {
1968 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1969 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
1970 //zprint2("Summoner Script UID: %d\n",this->script_UID);
1971
1972 }
1973 }
1974
1975 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
1976 }
1977
1978 break;
1979 }
1980
1981 case e1tSUMMONLAYER: // Summoner
1982 {
1983 if(count_layer_enemies()==0)
1984 {
1985 break;
1986 }
1987
1988 int32_t kids = guys.Count();
1989
1990 if(kids<40)
1991 {
1992 int32_t newguys=(zc_oldrand()%3)+1;
1993 bool summoned=false;
1994
1995 for(int32_t i=0; i<newguys; i++)
1996 {
1997 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
1998 int32_t x2=0;
1999 int32_t y2=0;
2000
2001 for(int32_t k=0; k<20; ++k)
2002 {
2003 x2=16*((zc_oldrand()%12)+2);
2004 y2=16*((zc_oldrand()%7)+2);
2005
2006 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2007 {
2008 //zprint2("summon\n");
2009 //al_trace("summon\n");
2010 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
2011 {
2012 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2013 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
2014 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
2015 {
2016 ((enemy*)guys.spr(kids+i))->fakez = 64;
2017 ((enemy*)guys.spr(kids+i))->z = 0;
2018 }
2019 }
2020
2021 summoned=true;
2022 break;
2023 }
2024 }
2025 }
2026
2027 if(summoned)
2028 {
2029 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2030 }
2031 }
2032
2033 break;
2034 }
2035 }
2036 28218 }
2037
2038
2039 // Hit the shield(s)?
2040 // Apparently, this function is only used for hookshots...
2041 398 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2042 {
2043
4/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 292 times.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
398 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2044 106 return false;
2045
2046 292 bool ret = false;
2047
2048 // TODO: There must be some bitwise operations that can simplify this...
2049
9/12
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 129 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 129 times.
✓ Branch 10 taken 129 times.
✗ Branch 11 not taken.
292 if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right));
2050
9/12
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 82 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
155 else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left));
2051
2052
11/14
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 185 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 95 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 101 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 101 times.
✓ Branch 12 taken 101 times.
✗ Branch 13 not taken.
300 if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down));
2053
10/14
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 144 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 141 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 141 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 141 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 141 times.
185 else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up));
2054
2055 300 return ret;
2056 406 }
2057
2058
2059 //! Weapon Editor for 2.6
2060 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2061
2062
2063 //converts a wqeapon ID to its defence index.
2064 73090 int32_t weaponToDefence(int32_t wid)
2065 {
2066
20/44
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 32485 times.
✓ Branch 3 taken 6764 times.
✓ Branch 4 taken 18964 times.
✓ Branch 5 taken 702 times.
✓ Branch 6 taken 28 times.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1549 times.
✓ Branch 10 taken 7171 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 163 times.
✓ Branch 14 taken 1166 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 322 times.
✓ Branch 18 taken 920 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 866 times.
✓ Branch 21 taken 406 times.
✓ Branch 22 taken 118 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 325 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 11 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 12 times.
✓ Branch 34 taken 77 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 993 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
73090 switch(wid)
2067 {
2068 case wNone: return -1;
2069 32485 case wSword: return edefSWORD;
2070 6764 case wBeam: return edefBEAM;
2071 18964 case wBrang: return edefBRANG;
2072 702 case wBomb: return edefBOMB;
2073 28 case wSBomb: return edefSBOMB;
2074 48 case wLitBomb: return edefBOMB;
2075 case wLitSBomb: return edefSBOMB;
2076 1549 case wArrow: return edefARROW;
2077 7171 case wFire: return edefFIRE;
2078 case wWhistle:
2079 {
2080 //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle");
2081 return edefWhistle;
2082 }
2083 case wBait: return edefBAIT;
2084 163 case wWand: return edefWAND;
2085 1166 case wMagic: return edefMAGIC;
2086 case wCatching: return -1;
2087 case wWind: return edefWIND;
2088 322 case wRefMagic: return edefREFMAGIC;
2089 920 case wRefFireball: return edefREFBALL;
2090 case wRefRock: return edefREFROCK;
2091 866 case wHammer: return edefHAMMER;
2092 406 case wHookshot: return edefHOOKSHOT;
2093 118 case wHSHandle: return edefHOOKSHOT;
2094 case wHSChain: return edefHOOKSHOT;
2095 case wSSparkle: return edefSPARKLE;
2096 325 case wFSparkle: return edefSPARKLE;
2097 case wSmack: return -1; // is this the candle object?
2098 case wPhantom: return -1; //engine created visual effects.
2099 case wCByrna: return edefBYRNA;
2100 11 case wRefBeam: return edefREFBEAM;
2101 case wStomp: return edefSTOMP;
2102 case wScript1: return edefSCRIPT01;
2103 case wScript2: return edefSCRIPT02;
2104 12 case wScript3: return edefSCRIPT03;
2105 77 case wScript4: return edefSCRIPT04;
2106 case wScript5: return edefSCRIPT05;
2107 case wScript6: return edefSCRIPT06;
2108 case wScript7: return edefSCRIPT07;
2109 case wScript8: return edefSCRIPT08;
2110 case wScript9: return edefSCRIPT09;
2111 993 case wScript10: return edefSCRIPT10;
2112 case wIce: return edefICE;
2113 case wSound: return edefSONIC;
2114 case wThrown: return edefTHROWN;
2115 //case wPot: return edefPOT;
2116 // case wLitZap: return edefELECTRIC;
2117 // case wZ3Sword: return edefZ3SWORD;
2118 // case wLASWord: return edefLASWORD;
2119 // case wSpinAttk: return edefSPINATTK;
2120 // case wShield: return edefSHIELD;
2121 // case wTrowel: return edefTROWEL;
2122
2123 default: return -1;
2124 }
2125 73090 }
2126
2127 73090 int32_t getDefType(weapon *w)
2128 {
2129 73090 int32_t id = getWeaponID(w);
2130 73090 int32_t edef = weaponToDefence(id);
2131
2/2
✓ Branch 0 taken 72566 times.
✓ Branch 1 taken 524 times.
73090 if(edef == edefHOOKSHOT)
2132 {
2133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
524 if(w->family_class == itype_switchhook)
2134 return edefSwitchHook;
2135 524 }
2136 73090 return edef;
2137 73090 }
2138
2139 126810 int32_t getWeaponID(weapon *w)
2140 {
2141 126810 int32_t usewpn = w->useweapon;
2142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126810 times.
126810 return (usewpn > 0) ? usewpn : w->id;
2143 }
2144
2145 73090 int32_t enemy::resolveEnemyDefence(weapon *w)
2146 {
2147 //sword edef is 9, but we're reading it at 0
2148 //,
2149 73090 int32_t weapondef = 0;
2150 73090 int32_t wdeftype = getDefType(w);
2151 73090 int32_t usedef = w->usedefence;
2152
2153
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 73090 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
73090 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2154 {
2155 weapondef = usedef*-1;
2156 }
2157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73090 times.
73090 else if(unsigned(wdeftype) < edefLAST255)
2158 {
2159 73090 weapondef = wdeftype;
2160 73090 }
2161 73090 return weapondef;
2162 }
2163
2164 79108 byte get_def_ignrflag(int32_t edef)
2165 {
2166
3/3
✓ Branch 0 taken 66047 times.
✓ Branch 1 taken 2329 times.
✓ Branch 2 taken 10732 times.
79108 switch(edef)
2167 {
2168 case edIGNORE:
2169 case edIGNOREL1:
2170 case edSTUNORIGNORE:
2171 10732 return WPNUNB_IGNR;
2172 case edSTUNORCHINK:
2173 case edCHINK:
2174 case edCHINKL1:
2175 case edCHINKL2:
2176 case edCHINKL4:
2177 case edCHINKL6:
2178 case edCHINKL8:
2179 case edCHINKL10:
2180 case edLEVELCHINK2:
2181 case edLEVELCHINK3:
2182 case edLEVELCHINK4:
2183 case edLEVELCHINK5:
2184 2329 return WPNUNB_BLOCK;
2185 }
2186 66047 return 0;
2187 79108 }
2188
2189 79108 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2190 {
2191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79108 times.
79108 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2192 switch(edef)
2193 {
2194 case edIGNORE:
2195 case edIGNOREL1:
2196 case edCHINK:
2197 case edCHINKL1:
2198 case edCHINKL2:
2199 case edCHINKL4:
2200 case edCHINKL6:
2201 case edCHINKL8:
2202 case edCHINKL10:
2203 case edLEVELCHINK2:
2204 case edLEVELCHINK3:
2205 case edLEVELCHINK4:
2206 case edLEVELCHINK5:
2207 return edNORMAL;
2208 case edSTUNORIGNORE:
2209 case edSTUNORCHINK:
2210 return edSTUNONLY;
2211 }
2212 return edef;
2213 79108 }
2214
2215 // Do we do damage?
2216 // 0: takehit returns 0
2217 // 1: takehit returns 1
2218 // -1: do damage
2219 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2220 72097 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2221 {
2222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 if(switch_hooked) return 0;
2223 72097 int32_t tempx = x;
2224 72097 int32_t tempy = y;
2225 72097 int32_t the_defence = 0;
2226
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2227 {
2228 the_defence = edef*-1; //A specific defence type.
2229 }
2230 72097 else the_defence = defense[edef];
2231
2232 72097 the_defence = conv_edef_unblockable(the_defence, unblockable);
2233
2234
3/4
✓ Branch 0 taken 4350 times.
✓ Branch 1 taken 67747 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4350 times.
72097 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2235 {
2236
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4343 times.
✓ Branch 2 taken 7 times.
4350 switch(the_defence)
2237 {
2238 case edIGNORE:
2239 7 return 0;
2240 case edIGNOREL1:
2241 case edSTUNORIGNORE:
2242 if(*power <= 0)
2243 return 0;
2244 }
2245 4343 sfx(WAV_CHINK,pan(int32_t(x)));
2246 4343 return 1;
2247 }
2248
2249 67747 int32_t new_id = id;
2250 67747 int32_t effect_type = dmisc15;
2251 67747 int32_t delay_timer = 90;
2252 67747 enemy *gleeok = NULL;
2253 67747 enemy *ptra = NULL;
2254 67747 int32_t c = 0;
2255
2256
15/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 322 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1413 times.
✓ Branch 6 taken 902 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 80 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 199 times.
✓ Branch 13 taken 9312 times.
✓ Branch 14 taken 173 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1789 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 79 times.
✓ Branch 26 taken 58 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 53312 times.
67747 switch(the_defence)
2257 {
2258 case edREPLACE:
2259 {
2260 sclk = 0;
2261 if ( dmisc16 > 0 ) new_id = dmisc16;
2262 else new_id = id+1;
2263 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2264 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2265 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2266
2267 //Z_scripterrlog("new id is %d\n", new_id);
2268 switch(guysbuf[new_id&0xFFF].family)
2269 {
2270 //Fixme: possible enemy memory leak. (minor)
2271 case eeWALK:
2272 {
2273 enemy *e = new eStalfos(x,y,new_id,clk);
2274 guys.add(e);
2275 }
2276 break;
2277
2278 case eeLEV:
2279 {
2280 enemy *e = new eLeever(x,y,new_id,clk);
2281 guys.add(e);
2282 }
2283 break;
2284
2285 case eeTEK:
2286 {
2287 enemy *e = new eTektite(x,y,new_id,clk);
2288 guys.add(e);
2289 }
2290 break;
2291
2292 case eePEAHAT:
2293 {
2294 enemy *e = new ePeahat(x,y,new_id,clk);
2295 guys.add(e);
2296 }
2297 break;
2298
2299 case eeZORA:
2300 {
2301 enemy *e = new eZora(x,y,new_id,clk);
2302 guys.add(e);
2303 }
2304 break;
2305
2306 case eeGHINI:
2307 {
2308 enemy *e = new eGhini(x,y,new_id,clk);
2309 guys.add(e);
2310 }
2311 break;
2312
2313 case eeKEESE:
2314 {
2315 enemy *e = new eKeese(x,y,new_id,clk);
2316 guys.add(e);
2317 }
2318 break;
2319
2320 case eeWIZZ:
2321 {
2322 enemy *e = new eWizzrobe(x,y,new_id,clk);
2323 guys.add(e);
2324 }
2325 break;
2326
2327 case eePROJECTILE:
2328 {
2329 enemy *e = new eProjectile(x,y,new_id,clk);
2330 guys.add(e);
2331 }
2332 break;
2333
2334 case eeWALLM:
2335 {
2336 enemy *e = new eWallM(x,y,new_id,clk);
2337 guys.add(e);
2338 }
2339 break;
2340
2341 case eeAQUA:
2342 {
2343 enemy *e = new eAquamentus(x,y,new_id,clk);
2344 guys.add(e);
2345 e->x = x;
2346 e->y = y;
2347 }
2348 break;
2349
2350 case eeMOLD:
2351 {
2352 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)));
2353 guys.add(e);
2354 e->x = x;
2355 e->y = y;
2356 }
2357 break;
2358
2359 case eeMANHAN:
2360 {
2361 enemy *e = new eManhandla(x,y,new_id,clk);
2362 guys.add(e);
2363 e->x = x;
2364 e->y = y;
2365 }
2366 break;
2367
2368 case eeGLEEOK:
2369 {
2370 *power = 0;
2371 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1);
2372 guys.add(gleeok);
2373 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2374 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2375 new_id &= 0xFFF;
2376 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2377 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2378 for(int32_t i=0; i<head_cnt; i++)
2379 {
2380 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2381 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2382 {
2383 al_trace("Gleeok head %d could not be created!\n",i+1);
2384
2385 for(int32_t j=0; j<i+1; j++)
2386 {
2387 guys.del(guys.Count()-1);
2388 }
2389
2390 break;
2391 }
2392 else
2393 {
2394 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2395 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2396 }
2397
2398 c-=guysbuf[new_id].misc4;
2399 //gleeok->x = x;
2400 //gleeok->y = y;
2401 //gleeok = e;
2402 }
2403 return 1;
2404 }
2405
2406 case eeGHOMA:
2407 {
2408 enemy *e = new eGohma(x,y,new_id,clk);
2409 guys.add(e);
2410 e->x = x;
2411 e->y = y;
2412 }
2413 break;
2414
2415 case eeLANM:
2416 {
2417 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)));
2418 guys.add(e);
2419 e->x = x;
2420 e->y = y;
2421 }
2422 break;
2423
2424 case eeGANON:
2425 {
2426 enemy *e = new eGanon(x,y,new_id,clk);
2427 guys.add(e);
2428 e->x = x;
2429 e->y = y;
2430 }
2431 break;
2432
2433 case eeFAIRY:
2434 {
2435 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2436 guys.add(e);
2437 e->x = x;
2438 e->y = y;
2439 }
2440 break;
2441
2442 case eeFIRE:
2443 {
2444 enemy *e = new eFire(x,y,new_id,clk);
2445 guys.add(e);
2446 e->x = x;
2447 e->y = y;
2448 }
2449 break;
2450
2451 case eeOTHER:
2452 {
2453 enemy *e = new eOther(x,y,new_id,clk);
2454 guys.add(e);
2455 e->x = x;
2456 e->y = y;
2457 }
2458 break;
2459
2460 case eeSPINTILE:
2461 {
2462 enemy *e = new eSpinTile(x,y,new_id,clk);
2463 guys.add(e);
2464 e->x = x;
2465 e->y = y;
2466 }
2467 break;
2468
2469 // and these enemies use the misc10/misc2 value
2470 case eeROCK:
2471 {
2472 switch(guysbuf[new_id&0xFFF].misc10)
2473 {
2474 case 1:
2475 {
2476 enemy *e = new eBoulder(x,y,new_id,clk);
2477 guys.add(e);
2478 e->x = x;
2479 e->y = y;
2480 }
2481 break;
2482
2483 case 0:
2484 default:
2485 {
2486 enemy *e = new eRock(x,y,new_id,clk);
2487 guys.add(e);
2488 e->x = x;
2489 e->y = y;
2490 }
2491 break;
2492 }
2493
2494 break;
2495 }
2496
2497 case eeTRAP:
2498 {
2499 switch(guysbuf[new_id&0xFFF].misc2)
2500 {
2501 case 1:
2502 {
2503 enemy *e = new eTrap2(x,y,new_id,clk);
2504 guys.add(e);
2505 e->x = x;
2506 e->y = y;
2507 }
2508 break;
2509
2510 case 0:
2511 default:
2512 {
2513 enemy *e = new eTrap(x,y,new_id,clk);
2514 guys.add(e);
2515 e->x = x;
2516 e->y = y;
2517 }
2518 break;
2519 }
2520
2521 break;
2522 }
2523
2524 case eeDONGO:
2525 {
2526 switch(guysbuf[new_id&0xFFF].misc10)
2527 {
2528 case 1:
2529 {
2530 enemy *e = new eDodongo2(x,y,new_id,clk);
2531 guys.add(e);
2532 e->x = x;
2533 e->y = y;
2534 }
2535 break;
2536
2537 case 0:
2538 default:
2539 {
2540 enemy *e = new eDodongo(x,y,new_id,clk);
2541 guys.add(e);
2542 e->x = x;
2543 e->y = y;
2544 }
2545 break;
2546 }
2547
2548 break;
2549 }
2550
2551 case eeDIG:
2552 {
2553 switch(guysbuf[new_id&0xFFF].misc10)
2554 {
2555 case 1:
2556 {
2557 enemy *e = new eLilDig(x,y,new_id,clk);
2558 guys.add(e);
2559 e->x = x;
2560 e->y = y;
2561 }
2562 break;
2563
2564 case 0:
2565 default:
2566 {
2567 enemy *e = new eBigDig(x,y,new_id,clk);
2568 guys.add(e);
2569 e->x = x;
2570 e->y = y;
2571 }
2572 break;
2573 }
2574
2575 break;
2576 }
2577
2578 case eePATRA:
2579 {
2580 switch(guysbuf[new_id&0xFFF].misc10)
2581 {
2582 case 1:
2583 {
2584 if (get_qr(qr_HARDCODED_BS_PATRA))
2585 {
2586 enemy *e = new ePatraBS(x,y,new_id,clk);
2587 guys.add(e);
2588 e->x = x;
2589 e->y = y;
2590 break;
2591 }
2592 }
2593 [[fallthrough]];
2594 case 0:
2595 default:
2596 {
2597 enemy *e = new ePatra(x,y,new_id,clk);
2598 guys.add(e);
2599 e->x = x;
2600 e->y = y;
2601 }
2602 break;
2603 }
2604
2605 break;
2606 }
2607
2608 case eeGUY:
2609 {
2610 switch(guysbuf[new_id&0xFFF].misc10)
2611 {
2612 case 1:
2613 {
2614 enemy *e = new eTrigger(x,y,new_id,clk);
2615 guys.add(e);
2616 }
2617 break;
2618
2619 case 0:
2620 default:
2621 {
2622 enemy *e = new eNPC(x,y,new_id,clk);
2623 guys.add(e);
2624 }
2625 break;
2626 }
2627
2628 break;
2629 }
2630
2631 case eeSCRIPT01:
2632 case eeSCRIPT02:
2633 case eeSCRIPT03:
2634 case eeSCRIPT04:
2635 case eeSCRIPT05:
2636 case eeSCRIPT06:
2637 case eeSCRIPT07:
2638 case eeSCRIPT08:
2639 case eeSCRIPT09:
2640 case eeSCRIPT10:
2641 case eeSCRIPT11:
2642 case eeSCRIPT12:
2643 case eeSCRIPT13:
2644 case eeSCRIPT14:
2645 case eeSCRIPT15:
2646 case eeSCRIPT16:
2647 case eeSCRIPT17:
2648 case eeSCRIPT18:
2649 case eeSCRIPT19:
2650 case eeSCRIPT20:
2651 {
2652 enemy *e = new eScript(x,y,new_id,clk);
2653 guys.add(e);
2654 e->x = x;
2655 e->y = y;
2656 break;
2657 }
2658
2659
2660 case eeFFRIENDLY01:
2661 case eeFFRIENDLY02:
2662 case eeFFRIENDLY03:
2663 case eeFFRIENDLY04:
2664 case eeFFRIENDLY05:
2665 case eeFFRIENDLY06:
2666 case eeFFRIENDLY07:
2667 case eeFFRIENDLY08:
2668 case eeFFRIENDLY09:
2669 case eeFFRIENDLY10:
2670 {
2671 enemy *e = new eFriendly(x,y,new_id,clk);
2672 guys.add(e);
2673 e->x = x;
2674 e->y = y;
2675 break;
2676 }
2677
2678
2679 default: break;
2680 }
2681
2682 // add segments of segmented enemies
2683 int32_t c=0;
2684
2685 switch(guysbuf[new_id&0xFFF].family)
2686 {
2687 case eeMOLD:
2688 {
2689 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2690 new_id &= 0xFFF;
2691
2692 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++)
2693 {
2694 //christ this is messy -DD
2695 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2696
2697 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2698 {
2699 al_trace("Moldorm segment %d could not be created!\n",i+1);
2700
2701 for(int32_t j=0; j<i+1; j++)
2702 guys.del(guys.Count()-1);
2703
2704 return 0;
2705 }
2706
2707 if(i>0)
2708 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2709
2710
2711 }
2712
2713 break;
2714 }
2715
2716 case eeLANM:
2717 {
2718 new_id &= 0xFFF;
2719 int32_t shft = guysbuf[new_id].misc2;
2720 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2721 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2722
2723 if(!guys.add(e))
2724 {
2725 al_trace("Lanmola segment 1 could not be created!\n");
2726 guys.del(guys.Count()-1);
2727 return 0;
2728 }
2729 e->x = x;
2730 e->y = y;
2731
2732
2733
2734 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++)
2735 {
2736 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2737 if(!guys.add(e2))
2738 {
2739 al_trace("Lanmola segment %d could not be created!\n",i+1);
2740
2741 for(int32_t j=0; j<i+1; j++)
2742 guys.del(guys.Count()-1);
2743
2744 return 0;
2745 }
2746 e2->x = x;
2747 e2->y = y;
2748
2749 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2750
2751 }
2752 }
2753 break;
2754
2755 case eeMANHAN:
2756 new_id &= 0xFFF;
2757
2758 for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++)
2759 {
2760 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2761 {
2762 al_trace("Manhandla head %d could not be created!\n",i+1);
2763
2764 for(int32_t j=0; j<i+1; j++)
2765 {
2766 guys.del(guys.Count()-1);
2767 }
2768
2769 return 0;
2770 }
2771
2772
2773 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1;
2774 }
2775
2776 break;
2777
2778 case eeGLEEOK:
2779 {
2780 /*
2781 new_id &= 0xFFF;
2782 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2783 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2784 for(int32_t i=0; i<head_cnt; i++)
2785 {
2786 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2787 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2788 {
2789 al_trace("Gleeok head %d could not be created!\n",i+1);
2790
2791 for(int32_t j=0; j<i+1; j++)
2792 {
2793 guys.del(guys.Count()-1);
2794 }
2795
2796 break;
2797 }
2798
2799 c-=guysbuf[new_id].misc4;
2800 */
2801
2802 // }
2803 }
2804 break;
2805
2806
2807 case eePATRA:
2808 {
2809 new_id &= 0xFFF;
2810 int32_t outeyes = 0;
2811 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2812
2813 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++)
2814 {
2815 if(!((guysbuf[new_id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2816 {
2817 al_trace("Patra outer eye %d could not be created!\n",i+1);
2818
2819 for(int32_t j=0; j<i+1; j++)
2820 guys.del(guys.Count()-1);
2821
2822 return 0;
2823 }
2824 else
2825 outeyes++;
2826
2827
2828 }
2829
2830 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++)
2831 {
2832 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2833 {
2834 al_trace("Patra inner eye %d could not be created!\n",i+1);
2835
2836 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2837 guys.del(guys.Count()-1);
2838
2839 return 0;
2840 }
2841
2842
2843 }
2844 delete ptra;
2845 break;
2846 }
2847 }
2848
2849
2850
2851 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2852 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2853 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2854 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2855 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2856 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2857 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2858 //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core.
2859 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2860 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2861 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2862 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2863 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
2864 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2865
2866
2867 item_set = 0; //Do not make a drop.
2868
2869 switch(effect_type)
2870 {
2871 case -7:
2872 {
2873 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2874 Lwpns.add(w);
2875 break;
2876 }
2877 case -6:
2878 {
2879 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2880 Lwpns.add(w);
2881 break;
2882 }
2883 case -5:
2884 {
2885 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2886 Lwpns.add(w);
2887 break;
2888 }
2889 case -4:
2890 {
2891 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2892 Lwpns.add(w);
2893 break;
2894 }
2895 case -3: explode(1); break;
2896 case -2: explode(2); break;
2897 case -1: explode(0); break;
2898 case 0: break;
2899
2900 default:
2901 {
2902 //Dummy weapon function
2903 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2904 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2905 Lwpns.add(w);
2906 break;
2907 }
2908 }
2909
2910
2911 yofs = -32768;
2912 switch(guysbuf[new_id&0xFFF].family)
2913 {
2914 case eeGLEEOK:
2915 {
2916 Z_scripterrlog("Replacing a gleeok.\n");
2917 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2918 hp = -999;
2919 tempenemy->hp = -999;
2920 break;
2921
2922 }
2923 default:
2924 hp = -1000; break;
2925 }
2926 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
2927 return 1;
2928
2929 }
2930 case edSPLIT:
2931 {
2932 //int32_t ex = x; int32_t ey = y;
2933 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2934 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2935 /*
2936 if ( txsx > 1 )
2937 {
2938 ex += ( txsz-1 ) * 8; //from its middle
2939 }
2940 if ( tysx > 1 )
2941 {
2942 ey += ( tysz-1 ) * 8; //from its middle
2943 }
2944 */
2945 for ( int32_t q = 0; q < dmisc4; q++ )
2946 {
2947
2948 //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15);
2949 addenemy(
2950 //ex,ey,
2951 x,y,
2952 dmisc3+0x1000,-15);
2953 //addenemy(ex,ey,dmisc3,0);
2954
2955 }
2956 item_set = 0; //Do not make a drop.
2957 hp = -1000;
2958 return -1;
2959
2960 }
2961 case edSUMMON:
2962 {
2963
2964
2965 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2966 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2967 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2968 for ( int32_t q = 0; q < summon_count; q++ )
2969 {
2970 int32_t x2=16*((zc_oldrand()%12)+2);
2971 int32_t y2=16*((zc_oldrand()%7)+2);
2972 addenemy(
2973 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2974 x2,y2,
2975 dmisc3+0x1000,-15);
2976 //addenemy(ex,ey,dmisc3,0);
2977
2978 }
2979 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2980 return -1;
2981
2982 }
2983
2984 case edEXPLODESMALL:
2985 {
2986 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2987 Ewpns.add(ew);
2988 item_set = 0; //Should we make a drop?
2989 hp = -1000;
2990 return -1;
2991 }
2992
2993
2994 case edEXPLODEHARMLESS:
2995 {
2996 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2997 Ewpns.add(ew);
2998 ew->hyofs = -32768;
2999 item_set = 0; //Should we make a drop?
3000 hp = -1000;
3001 return -1;
3002 }
3003
3004
3005 case edEXPLODELARGE:
3006 {
3007 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
3008 Ewpns.add(ew);
3009
3010 hp = -1000;
3011 return -1;
3012 }
3013
3014
3015 case edTRIGGERSECRETS:
3016 {
3017 hidden_entrance(0, true, false, -4);
3018 return -1;
3019 }
3020
3021 case edSTUNORCHINK:
3022
3/4
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 948 times.
✗ Branch 3 not taken.
3067 if (stunclk && get_qr(qr_NO_STUNLOCK))
3023 {
3024 sfx(WAV_CHINK,pan(int32_t(x)));
3025 return 1;
3026 }
3027
2/2
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 1278 times.
1789 else if(*power <= 0)
3028 {
3029 //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK");
3030 511 sfx(WAV_CHINK,pan(int32_t(x)));
3031 511 return 1;
3032 }
3033 [[fallthrough]];
3034
3035 case edSTUNORIGNORE:
3036
3/4
✓ Branch 0 taken 1438 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1438 times.
✗ Branch 3 not taken.
4578 if (stunclk && get_qr(qr_NO_STUNLOCK))
3037 {
3038 sfx(WAV_CHINK,pan(int32_t(x)));
3039 return 1;
3040 }
3041
2/2
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 1887 times.
2691 else if(*power <= 0)
3042 804 return 0;
3043 [[fallthrough]];
3044
3045 case edSTUNONLY:
3046
7/10
✓ Branch 0 taken 2789 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2789 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2789 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2733 times.
✓ Branch 7 taken 56 times.
✓ Branch 8 taken 2760 times.
✓ Branch 9 taken 29 times.
2789 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3047 {
3048 //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3049 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3050 29 return 1;
3051 }
3052
3/4
✓ Branch 0 taken 2135 times.
✓ Branch 1 taken 625 times.
✓ Branch 2 taken 2135 times.
✗ Branch 3 not taken.
2760 if (stunclk && get_qr(qr_NO_STUNLOCK))
3053 {
3054 sfx(WAV_CHINK,pan(int32_t(x)));
3055 return 1;
3056 }
3057 else
3058 {
3059 2760 stunclk=160;
3060 2760 sfx(WAV_EHIT,pan(int32_t(x)));
3061
3062 2760 return 1;
3063 }
3064
3065 case edCHINKL1:
3066 if(*power >= 1*game->get_hero_dmgmult()) break;
3067 [[fallthrough]];
3068 case edCHINKL2:
3069
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(*power >= 2*game->get_hero_dmgmult()) break;
3070 [[fallthrough]];
3071 case edCHINKL4:
3072
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 19 times.
80 if(*power >= 4*game->get_hero_dmgmult()) break;
3073 [[fallthrough]];
3074 case edCHINKL6:
3075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 6*game->get_hero_dmgmult()) break;
3076 [[fallthrough]];
3077 case edCHINKL8:
3078
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 20 times.
35 if(*power >= 8*game->get_hero_dmgmult()) break;
3079 [[fallthrough]];
3080 case edCHINKL10:
3081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 10*game->get_hero_dmgmult()) break;
3082 [[fallthrough]];
3083 case edCHINK:
3084 //al_trace("defendNew() is at: %s\n", "returning edCHINK");
3085 219 sfx(WAV_CHINK,pan(int32_t(x)));
3086 219 return 1;
3087
3088 case edIGNOREL1:
3089 if(*power > 0) break;
3090 [[fallthrough]];
3091
3092 case edIGNORE:
3093 9312 return 0;
3094
3095 case ed1HKO:
3096 322 *power = hp;
3097 322 return -2;
3098
3099 case ed2x:
3100 {
3101
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3102 //int32_t pow = *power;
3103 //*power = vbound((pow*2),0,214747);
3104 71 return -1;
3105 }
3106 case ed3x:
3107 {
3108 *power = zc_max(1,*power*3);
3109 //int32_t pow = *power;
3110 //*power = vbound((pow*3),0,214747);
3111 return -1;
3112 }
3113
3114 case ed4x:
3115 {
3116 *power = zc_max(1,*power*4);
3117 //int32_t pow = *power;
3118 //*power = vbound((pow*4),0,214747);
3119 return -1;
3120 }
3121
3122
3123 case edHEAL:
3124 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3125 //int32_t pow = *power;
3126 //*power = vbound((pow*-1),0,214747);
3127 //break;
3128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 *power = zc_min(0,*power*-1);
3129 79 return -1;
3130 }
3131 /*
3132 case edLEVELDAMAGE:
3133 {
3134 int32_t pow = *power;
3135 int32_t lvl = *level;
3136 *power = vbound((pow*lvl),0,214747);
3137 break;
3138 }
3139 case edLEVELREDUCTION:
3140 {
3141 int32_t pow = *power;
3142 int32_t lvl = *level;
3143 *power = vbound((pow/lvl),0,214747);
3144 break;
3145 }
3146 */
3147
3148 case edQUARTDAMAGE:
3149
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 1 times.
58 *power = zc_max(1,*power/2);
3150
3151 [[fallthrough]];
3152 case edHALFDAMAGE:
3153
2/2
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 17 times.
231 *power = zc_max(1,*power/2);
3154 231 break;
3155
3156 case edSWITCH:
3157 {
3158 if(Hero.switchhookclk) return 0; //Already switching!
3159 switch(family)
3160 {
3161 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3162 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3163 return 0;
3164 }
3165 hooked_combopos = -1;
3166 hooked_layerbits = 0;
3167 switching_object = this;
3168 switch_hooked = true;
3169 Hero.doSwitchHook(game->get_switchhookstyle());
3170 if(QMisc.miscsfx[sfxSWITCHED])
3171 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3172 return 1;
3173 }
3174
3175 case 0:
3176 {
3177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53312 times.
53312 if(edef == edefSwitchHook)
3178 return -1;
3179
6/6
✓ Branch 0 taken 13877 times.
✓ Branch 1 taken 39435 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 13848 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 13 times.
53312 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3180 {
3181 13 sfx(WAV_CHINK,pan(int32_t(x)));
3182 13 return 1;
3183 }
3184
3185 }
3186 53299 }
3187
3188 53627 return -1;
3189 72097 }
3190
3191 72097 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3192 {
3193
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 int wuid = w?w->getUID():0;
3194
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3195
3196
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if(fakeweap)
3197 Lwpns.add(w);
3198 72097 std::vector<int32_t> &ev = FFCore.eventData;
3199 72097 ev.clear();
3200 72097 ev.push_back(*power*10000);
3201 72097 ev.push_back(edef*10000);
3202 72097 ev.push_back(unblockable*10000);
3203 72097 ev.push_back(wpnId*10000);
3204 72097 ev.push_back(0);
3205 72097 ev.push_back(getUID());
3206 72097 ev.push_back(wuid);
3207
3208 72097 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3209 72097 *power = ev[0]/10000;
3210 72097 edef = ev[1]/10000;
3211 72097 unblockable = byte(ev[2]/10000);
3212 72097 wpnId = ev[3] / 10000;
3213 72097 bool nullify = ev[4]!=0;
3214 72097 ev.clear();
3215 72097 int ret = 0;
3216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 if(!nullify)
3217 {
3218 72097 ret = defendNew(wpnId, power, edef, unblockable);
3219
2/2
✓ Branch 0 taken 18999 times.
✓ Branch 1 taken 53098 times.
72097 if(ret == -1)
3220 {
3221 53098 ev.push_back(*power*10000);
3222 53098 ev.push_back(edef*10000);
3223 53098 ev.push_back(unblockable*10000);
3224 53098 ev.push_back(wpnId*10000);
3225 53098 ev.push_back(0);
3226 53098 ev.push_back(getUID());
3227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53098 times.
53098 ev.push_back(w?w->getUID():0);
3228
3229 53098 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3230 53098 *power = ev[0]/10000;
3231 53098 nullify = ev[4]!=0;
3232 53098 ev.clear();
3233 53098 }
3234 72097 }
3235
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if(fakeweap)
3236 Lwpns.remove(w);
3237
3238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 return nullify ? 0 : ret;
3239 }
3240
3241 53720 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3242 {
3243
2/2
✓ Branch 0 taken 53490 times.
✓ Branch 1 taken 230 times.
53720 if(!realweap) realweap = w;
3244 53720 int32_t wid = getWeaponID(w);
3245
3246 53720 int32_t edef = resolveEnemyDefence(w);
3247
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 52464 times.
53720 if(QHeader.zelda_version > 0x250)
3248 1256 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3249
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 51471 times.
✗ Branch 2 not taken.
52464 switch(wid)
3250 {
3251 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3252 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3253 993 return defend(wpnId, power, edefSCRIPT);
3254
3255 case wWhistle:
3256 return -1;
3257
3258 default:
3259 51471 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3260 }
3261 53720 }
3262
3263
3264 // Check defenses without actually acting on them.
3265 11966 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3266 {
3267
4/10
✓ Branch 0 taken 9574 times.
✓ Branch 1 taken 2059 times.
✓ Branch 2 taken 325 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11966 switch(defense[edef])
3268 {
3269 case edSTUNONLY:
3270 8 return false;
3271 case edSTUNORCHINK:
3272 case edCHINK:
3273 9574 return unblockable&WPNUNB_BLOCK;
3274 case edSTUNORIGNORE:
3275 case edIGNORE:
3276 2059 return unblockable&WPNUNB_IGNR;
3277
3278 case edIGNOREL1:
3279 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3280 case edCHINKL1:
3281 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3282
3283 case edCHINKL2:
3284 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3285
3286 case edCHINKL4:
3287 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3288
3289 case edCHINKL6:
3290 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3291
3292 case edCHINKL8:
3293 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3294 }
3295
3296 325 return true;
3297 11966 }
3298
3299 // Do we do damage?
3300 // 0: takehit returns 0
3301 // 1: takehit returns 1
3302 // -1: do damage
3303 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3304 {
3305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3306 {
3307 switch(defense[edef])
3308 {
3309 case edIGNORE:
3310 return 0;
3311 case edIGNOREL1:
3312 case edSTUNORIGNORE:
3313 if(*power <= 0)
3314 return 0;
3315 }
3316
3317 sfx(WAV_CHINK,pan(int32_t(x)));
3318 return 1;
3319 }
3320
3321
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3322 {
3323 case edSTUNORCHINK:
3324 if(*power <= 0)
3325 {
3326 sfx(WAV_CHINK,pan(int32_t(x)));
3327 return 1;
3328 }
3329
3330 [[fallthrough]];
3331 case edSTUNORIGNORE:
3332 if(*power <= 0)
3333 return 0;
3334
3335 [[fallthrough]];
3336 case edSTUNONLY:
3337 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3338 return 1;
3339
3340 stunclk=160;
3341 sfx(WAV_EHIT,pan(int32_t(x)));
3342 return 1;
3343
3344 case edFREEZE:
3345 frozenclock=-1;
3346 //sfx(WAV_FREEZE,pan(int32_t(x)));
3347 return 1;
3348
3349 case edCHINKL1:
3350 if(*power >= 1*game->get_hero_dmgmult()) break;
3351 [[fallthrough]];
3352 case edCHINKL2:
3353 if(*power >= 2*game->get_hero_dmgmult()) break;
3354 [[fallthrough]];
3355 case edCHINKL4:
3356 if(*power >= 4*game->get_hero_dmgmult()) break;
3357 [[fallthrough]];
3358 case edCHINKL6:
3359 if(*power >= 6*game->get_hero_dmgmult()) break;
3360 [[fallthrough]];
3361 case edCHINKL8:
3362 if(*power >= 8*game->get_hero_dmgmult()) break;
3363 [[fallthrough]];
3364 case edCHINKL10:
3365 if(*power >= 10*game->get_hero_dmgmult()) break;
3366 [[fallthrough]];
3367 case edCHINK:
3368 sfx(WAV_CHINK,pan(int32_t(x)));
3369 return 1;
3370 case edTRIGGERSECRETS:
3371 hidden_entrance(0, true, false, -4);
3372 break;
3373
3374 case edIGNOREL1:
3375 if(*power > 0) break;
3376 [[fallthrough]];
3377 case edIGNORE:
3378 800 return 0;
3379
3380 case ed1HKO:
3381 *power = hp;
3382 return -2;
3383
3384 case ed2x:
3385 {
3386 *power = zc_max(1,*power*2);
3387 //int32_t pow = *power;
3388 //*power = vbound((pow*2),0,214747);
3389 return -1;
3390 }
3391 case ed3x:
3392 {
3393 *power = zc_max(1,*power*3);
3394 //int32_t pow = *power;
3395 //*power = vbound((pow*3),0,214747);
3396 return -1;
3397 }
3398
3399 case ed4x:
3400 {
3401 *power = zc_max(1,*power*4);
3402 //int32_t pow = *power;
3403 //*power = vbound((pow*4),0,214747);
3404 return -1;
3405 }
3406
3407
3408 case edHEAL:
3409 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3410 //int32_t pow = *power;
3411 //*power = vbound((pow*-1),0,214747);
3412 //break;
3413 *power = zc_min(0,*power*-1);
3414 return -1;
3415 }
3416 /*
3417 case edLEVELDAMAGE:
3418 {
3419 int32_t pow = *power;
3420 int32_t lvl = *level;
3421 *power = vbound((pow*lvl),0,214747);
3422 break;
3423 }
3424 case edLEVELREDUCTION:
3425 {
3426 int32_t pow = *power;
3427 int32_t lvl = *level;
3428 *power = vbound((pow/lvl),0,214747);
3429 break;
3430 }
3431 */
3432
3433
3434 case edQUARTDAMAGE:
3435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3436
3437 [[fallthrough]];
3438 case edHALFDAMAGE:
3439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3440 7 break;
3441 }
3442
3443 193 return -1;
3444 993 }
3445
3446 // Defend against a particular item class.
3447 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3448 {
3449 int32_t def=-1;
3450
3451 switch(wpnId)
3452 {
3453 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3454 case wBrang:
3455 def = defend(wpnId, power, edefBRANG);
3456 break;
3457
3458 case wHookshot:
3459 def = defend(wpnId, power, edefHOOKSHOT);
3460 break;
3461
3462 // Anyway...
3463 case wBomb:
3464 def = defend(wpnId, power, edefBOMB);
3465 break;
3466
3467 case wSBomb:
3468 def = defend(wpnId, power, edefSBOMB);
3469 break;
3470
3471 case wArrow:
3472 def = defend(wpnId, power, edefARROW);
3473 break;
3474
3475 case wFire:
3476 def = defend(wpnId, power, edefFIRE);
3477 break;
3478
3479 case wWand:
3480 def = defend(wpnId, power, edefWAND);
3481 break;
3482
3483 case wMagic:
3484 def = defend(wpnId, power, edefMAGIC);
3485 break;
3486
3487 case wHammer:
3488 def = defend(wpnId, power, edefHAMMER);
3489 break;
3490
3491 case wSword:
3492 def = defend(wpnId, power, edefSWORD);
3493 break;
3494
3495 case wBeam:
3496 def = defend(wpnId, power, edefBEAM);
3497 break;
3498
3499 case wRefBeam:
3500 def = defend(wpnId, power, edefREFBEAM);
3501 break;
3502
3503 case wRefMagic:
3504 def = defend(wpnId, power, edefREFMAGIC);
3505 break;
3506
3507 case wRefFireball:
3508 def = defend(wpnId, power, edefREFBALL);
3509 break;
3510
3511 case wRefRock:
3512 def = defend(wpnId, power, edefREFROCK);
3513 break;
3514
3515 case wStomp:
3516 def = defend(wpnId, power, edefSTOMP);
3517 break;
3518
3519 case wCByrna:
3520 def = defend(wpnId, power, edefBYRNA);
3521 break;
3522
3523 case wScript1:
3524 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3525 else def = defend(wpnId, power, edefSCRIPT);
3526 break;
3527
3528 case wScript2:
3529 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3530 else def = defend(wpnId, power, edefSCRIPT);
3531 break;
3532
3533 case wScript3:
3534 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3535 else def = defend(wpnId, power, edefSCRIPT);
3536 break;
3537
3538 case wScript4:
3539 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3540 else def = defend(wpnId, power, edefSCRIPT);
3541 break;
3542
3543 case wScript5:
3544 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3545 else def = defend(wpnId, power, edefSCRIPT);
3546 break;
3547
3548 case wScript6:
3549 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3550 else def = defend(wpnId, power, edefSCRIPT);
3551 break;
3552
3553 case wScript7:
3554 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3555 else def = defend(wpnId, power, edefSCRIPT);
3556 break;
3557
3558 case wScript8:
3559 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3560 else def = defend(wpnId, power, edefSCRIPT);
3561 break;
3562
3563 case wScript9:
3564 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3565 else def = defend(wpnId, power, edefSCRIPT);
3566 break;
3567
3568 case wScript10:
3569 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3570 else def = defend(wpnId, power, edefSCRIPT);
3571 break;
3572
3573 case wWhistle:
3574 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3575 else break;
3576 break;
3577
3578
3579 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3580 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3581 //of the ten if the quest version is lower than N.
3582 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3583 //such as bool UseSeparatedScriptDefences. hah.
3584 default:
3585 //if(wpnId>=wScript1 && wpnId<=wScript10)
3586 // {
3587 // def = defend(wpnId, power, edefSCRIPT);
3588 // }
3589 // }
3590
3591 break;
3592 }
3593
3594 return def;
3595 }
3596
3597 // take damage or ignore it
3598 // -1: damage (if any) dealt
3599 // 1: blocked
3600 // 0: weapon passes through unhindered
3601 159739 int32_t enemy::takehit(weapon *w, weapon* realweap)
3602 {
3603
2/4
✓ Branch 0 taken 159739 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159739 times.
159739 if(fallclk||drownclk) return 0;
3604
2/2
✓ Branch 0 taken 34416 times.
✓ Branch 1 taken 125323 times.
159739 if(!realweap) realweap = w;
3605 159739 int32_t wpnId = w->id;
3606 159739 int32_t power = w->power;
3607 159739 int32_t wpnx = w->x;
3608 159739 int32_t wpny = w->y;
3609 159739 int32_t enemyHitWeapon = w->parentitem;
3610 int32_t wpnDir;
3611 159739 int32_t parent_item = w->parentitem;
3612
3613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159739 times.
159739 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3614 {
3615 wpnId = w->useweapon;
3616 }
3617
3618 // If it's a boomerang that just bounced, use the opposite direction;
3619 // otherwise, it might bypass a shield. This probably won't handle
3620 // every case correctly, but it's better than having shields simply
3621 // not work against boomerangs.
3622
8/8
✓ Branch 0 taken 18979 times.
✓ Branch 1 taken 140760 times.
✓ Branch 2 taken 11895 times.
✓ Branch 3 taken 7084 times.
✓ Branch 4 taken 11291 times.
✓ Branch 5 taken 604 times.
✓ Branch 6 taken 2653 times.
✓ Branch 7 taken 8638 times.
159739 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3623 8638 wpnDir = oppositeDir[w->dir];
3624 else
3625 151101 wpnDir = w->dir;
3626
3627
5/8
✓ Branch 0 taken 159739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159739 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159739 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 761 times.
✓ Branch 7 taken 160110 times.
159739 if(dying || clk<0 || hclk>0 || superman)
3628 761 return 0;
3629
3630 //Prevent boomerang from writing to hitby[] for more than one frame.
3631 //This also prevents stunlock.
3632 //if ( stunclk > 0 ) return 0;
3633 //this needs a rule for boomerangs that cannot stunlock!
3634 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3635 //sigh.
3636
3637 160110 int32_t ret = -1;
3638
3639 // This obscure quest rule...
3640
5/6
✓ Branch 0 taken 77360 times.
✓ Branch 1 taken 82750 times.
✓ Branch 2 taken 77192 times.
✓ Branch 3 taken 168 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 77192 times.
160110 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3641 {
3642 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3643 168 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3644 168 wpnDir=zc_oldrand()&3;
3645
3646
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
168 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3647 {
3648 59 wpnDir=down;
3649 59 }
3650
4/4
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 56 times.
109 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3651 {
3652 56 wpnDir=right;
3653 56 }
3654
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 14 times.
53 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3655 {
3656 14 wpnDir=up;
3657 14 }
3658 else
3659 {
3660 39 wpnDir=left;
3661 }
3662 168 }
3663
3664 160110 int32_t xdir = dir;
3665 160110 shieldCanBlock=false;
3666
3667 //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down;
3668
4/4
✓ Branch 0 taken 158266 times.
✓ Branch 1 taken 1844 times.
✓ Branch 2 taken 406 times.
✓ Branch 3 taken 157860 times.
160905 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3669
10/10
✓ Branch 0 taken 13418 times.
✓ Branch 1 taken 13012 times.
✓ Branch 2 taken 18111 times.
✓ Branch 3 taken 152761 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 152703 times.
✓ Branch 6 taken 984 times.
✓ Branch 7 taken 151719 times.
✓ Branch 8 taken 795 times.
✓ Branch 9 taken 150924 times.
158266 || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right))))
3670 )
3671 // The hammer should already be dealt with by subclasses (Walker etc.)
3672 {
3673
9/9
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 263 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 3758 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1317 times.
✓ Branch 8 taken 484 times.
33366 switch(wpnId)
3674 {
3675 // Weapons which shields protect against
3676 case wSword:
3677 case wWand:
3678
1/2
✓ Branch 0 taken 3758 times.
✗ Branch 1 not taken.
3758 if(Hero.getCharging()>0)
3679 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3680
3681 [[fallthrough]];
3682 case wHookshot:
3683 case wHSHandle:
3684 case wBrang:
3685 4021 shieldCanBlock=true;
3686 4273 break;
3687
3688 case wBeam:
3689 case wRefBeam:
3690 // Mirror shielded enemies!
3691 #if 0
3692 if(false /*flags2&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3693 {
3694 if(wpnId>wEnemyWeapons)
3695 return 0;
3696
3697 sfx(WAV_CHINK,pan(int32_t(x)));
3698 return 1;
3699 }
3700
3701 #endif
3702
3703 [[fallthrough]];
3704 case wRefRock:
3705 case wRefFireball:
3706 case wMagic:
3707 #if 0
3708 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3709 {
3710 sfx(WAV_CHINK,pan(int32_t(x)));
3711 return 3;
3712 }
3713
3714 #endif
3715
3716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(wpnId>wEnemyWeapons)
3717 return 0;
3718
3719 [[fallthrough]];
3720 default:
3721 1597 shieldCanBlock=true;
3722 1597 break;
3723
3724 // Bombs
3725 case wSBomb:
3726 case wBomb:
3727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3728 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3729 {
3730 sfx(WAV_CHINK,pan(int32_t(x)));
3731 return 0;
3732 }
3733 else break;
3734
3735 // Weapons which ignore shields
3736 case wWhistle:
3737 case wHammer:
3738 1 break;
3739
3740 // Weapons which shouldn't be removed by shields
3741 case wLitBomb:
3742 case wLitSBomb:
3743 case wWind:
3744 case wPhantom:
3745 case wSSparkle:
3746 case wBait:
3747 423 return 0;
3748
3749 case wFire:
3750 ;
3751 484 }
3752 6103 }
3753
3754
7/8
✓ Branch 0 taken 72714 times.
✓ Branch 1 taken 53047 times.
✓ Branch 2 taken 211 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11966 times.
✓ Branch 5 taken 18964 times.
✓ Branch 6 taken 406 times.
✓ Branch 7 taken 1563 times.
158871 switch(wpnId)
3755 {
3756 case wWhistle: //No longer completely ignore whistle weapons! -Z
3757 {
3758
3759
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211 if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3760 {
3761 //al_trace("Whistle weapon in %s\n", "takehit flag == 0");
3762 211 return 0; break;
3763 }
3764 else
3765 {
3766 w->power = power = itemsbuf[parent_item].misc5;
3767
3768 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3769
3770 if(def <= 0)
3771 {
3772 if ( def == -2 ) hp -= hp;
3773 else hp -= power;
3774 return def;
3775 }
3776 break;
3777 }
3778 break;
3779 }
3780
3781 case wPhantom:
3782 return 0;
3783
3784 case wLitBomb:
3785 case wLitSBomb:
3786 case wBait:
3787 case wWind:
3788 case wSSparkle:
3789 72714 return 0;
3790
3791 case wFSparkle:
3792
3793 // Only take sparkle damage if the sparkle's parent item is not
3794 // defended against.
3795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11966 times.
11966 if(enemyHitWeapon > -1)
3796 {
3797 11966 int32_t p = 0;
3798 11966 int32_t f = itemsbuf[enemyHitWeapon].family;
3799
3800
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11966 times.
11966 switch(f)
3801 {
3802 case itype_arrow:
3803 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3804
3805 break;
3806
3807 case itype_cbyrna:
3808 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3809
3810 break;
3811
3812 case itype_brang:
3813
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 11641 times.
11966 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3814
3815 325 break;
3816
3817 default:
3818 return 0;
3819 }
3820 325 }
3821
3822 325 wpnId = wSword;
3823 325 power = game->get_hero_dmgmult()>>1;
3824 325 goto fsparkle;
3825 break;
3826
3827 case wBrang:
3828 {
3829 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3830 18964 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3831 //preventing stunlock might be best, here. -Z
3832
2/2
✓ Branch 0 taken 4250 times.
✓ Branch 1 taken 14714 times.
18964 if(def >= 0) return def;
3833
3834 // Not hurt by 0-damage weapons
3835
2/2
✓ Branch 0 taken 2271 times.
✓ Branch 1 taken 12443 times.
14714 if(!(flags & guy_bhit))
3836 {
3837 12443 stunclk=160;
3838
3839
3/4
✓ Branch 0 taken 12443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1200 times.
✓ Branch 3 taken 11243 times.
12443 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3840 {
3841
1/2
✓ Branch 0 taken 1200 times.
✗ Branch 1 not taken.
1200 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3842 1200 goto hitclock;
3843 }
3844
3845 11243 break;
3846 }
3847
3848
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1887 times.
2271 if(!power)
3849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1887 times.
1887 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3850 else
3851 384 hp-=power;
3852
3853 2271 goto hitclock;
3854 }
3855
3856 case wHookshot:
3857 {
3858 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3859 406 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3860
3861
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 221 times.
406 if(def >= 0) return def;
3862
3863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221 times.
221 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3864
3/4
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 6 times.
221 if(swgrab || !(flags & guy_bhit))
3865 {
3866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(!swgrab)
3867 215 stunclk=160;
3868
3869
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
215 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3870 {
3871 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3872 goto hitclock;
3873 }
3874
3875 215 break;
3876 }
3877
3878
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3879 else
3880 hp-=power;
3881
3882 6 goto hitclock;
3883 }
3884 break;
3885
3886 case wHSHandle:
3887 {
3888
3/4
✓ Branch 0 taken 1563 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 1484 times.
1563 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1)
3889 79 return 0;
3890
3891
3/4
✓ Branch 0 taken 1093 times.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 391 times.
✗ Branch 3 not taken.
1484 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3892
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 391 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
391 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3893
3894 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3895
6/8
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 1032 times.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 452 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 370 times.
1801 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3896
6/6
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 651 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 334 times.
452 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right))))
3897 334 return 0;
3898
3899 2182 power = game->get_hero_dmgmult();
3900 2507 }
3901
3902 fsparkle:
3903
3904 [[fallthrough]];
3905 default:
3906 // Work out the defenses!
3907 {
3908 53490 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3909
3910
2/2
✓ Branch 0 taken 14920 times.
✓ Branch 1 taken 38570 times.
53490 if(def >= 0)
3911 14920 return def;
3912
2/2
✓ Branch 0 taken 38280 times.
✓ Branch 1 taken 290 times.
38570 else if(def == -2)
3913 {
3914 290 ret = 0;
3915 290 }
3916 }
3917
3918
2/2
✓ Branch 0 taken 38568 times.
✓ Branch 1 taken 2 times.
77140 if(!power)
3919 {
3920
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3921 2 hp-=1;
3922 else
3923 {
3924 // Don't make a long chain of 'stun' hits
3925 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3926 return 1;
3927
3928
3929 if(!switch_hooked)
3930 stunclk=160;
3931 break;
3932 }
3933 2 }
3934 38568 else hp-=power;
3935
3936 hitclock:
3937 42051 hclk=33;
3938
3939 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3940
2/2
✓ Branch 0 taken 19451 times.
✓ Branch 1 taken 22600 times.
42051 if((dir&2)==(w->dir&2))
3941 {
3942 22600 sclk=(w->dir<<8)+16;
3943 22600 }
3944 42051 }
3945
3946
5/6
✓ Branch 0 taken 38795 times.
✓ Branch 1 taken 14714 times.
✓ Branch 2 taken 6721 times.
✓ Branch 3 taken 46788 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6721 times.
53509 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3947 {
3948 6721 fading=fade_blue_poof;
3949 6721 }
3950
3951
6/6
✓ Branch 0 taken 52505 times.
✓ Branch 1 taken 1004 times.
✓ Branch 2 taken 34805 times.
✓ Branch 3 taken 17700 times.
✓ Branch 4 taken 1927 times.
✓ Branch 5 taken 32878 times.
53509 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3952 {
3953
1/2
✓ Branch 0 taken 2931 times.
✗ Branch 1 not taken.
2931 if( hitsfx > 0 ) //user-set hit sound.
3954 {
3955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2931 times.
2931 if (!dying) //don't play the hit sound on death! -Z
3956 2931 sfx(hitsfx, pan(int32_t(x)));
3957 2931 }
3958 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3959 2931 }
3960 else //2.50.2 or earlier
3961 {
3962 50578 sfx(WAV_EHIT, pan(int32_t(x)));
3963 50578 sfx(hitsfx, pan(int32_t(x)));
3964 }
3965
2/2
✓ Branch 0 taken 53499 times.
✓ Branch 1 taken 10 times.
53509 if(family==eeGUY)
3966 10 sfx(WAV_EDEAD, pan(int32_t(x)));
3967
3968 // Penetrating weapons
3969
4/4
✓ Branch 0 taken 52712 times.
✓ Branch 1 taken 797 times.
✓ Branch 2 taken 47718 times.
✓ Branch 3 taken 5791 times.
53509 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3970 {
3971 5791 int32_t item=enemyHitWeapon;
3972
3973
2/2
✓ Branch 0 taken 642 times.
✓ Branch 1 taken 5149 times.
5791 if(wpnId==wArrow)
3974 {
3975 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3976
5/6
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70 times.
642 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow))
3977 70 return 0;
3978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3979 //if(item<0)
3980 else
3981 572 item=current_item_id(itype_arrow);
3982 572 }
3983
3984 else
3985 {
3986
3987 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3988
3/6
✓ Branch 0 taken 5131 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5131 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5149 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword))
3989 return 0;
3990
3991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5149 times.
5149 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3992 else
3993 //if(item<0)
3994 5149 item=current_item_id(itype_sword);
3995 }
3996 5721 }
3997
3998 53439 return ret;
3999 159027 }
4000
4001 29337462 bool enemy::dont_draw()
4002 {
4003
6/6
✓ Branch 0 taken 29226987 times.
✓ Branch 1 taken 110475 times.
✓ Branch 2 taken 29156080 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 34083 times.
✓ Branch 5 taken 29192904 times.
29337462 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4004 144558 return true;
4005
4006
2/2
✓ Branch 0 taken 286146 times.
✓ Branch 1 taken 28906758 times.
29192904 if(flags&guy_invisible)
4007 286146 return true;
4008
4009
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 28906326 times.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
28906758 if(flags&lens_only && !lensclk)
4010 return true;
4011
4012
3/8
✓ Branch 0 taken 45951 times.
✓ Branch 1 taken 28860807 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45951 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28906758 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) &&
4013 !((flags&lens_only) && (get_qr(qr_LENSSEESENEMIES) || (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5))))
4014 return true;
4015
4016 28906758 return false;
4017 29337462 }
4018
4019 #define DRAW_NORMAL 2
4020 #define DRAW_CLOAKED 1
4021 #define DRAW_INVIS 0
4022 // base drawing function to be used by all derived classes instead of
4023 // sprite::draw()
4024 24870233 void enemy::draw(BITMAP *dest)
4025 {
4026 24870233 didScriptThisFrame = false; //Since there's no better place to put it
4027
6/6
✓ Branch 0 taken 24512538 times.
✓ Branch 1 taken 357695 times.
✓ Branch 2 taken 24429888 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 153900 times.
✓ Branch 5 taken 24358638 times.
24870233 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4028 511595 return;
4029
2/2
✓ Branch 0 taken 1573842 times.
✓ Branch 1 taken 22784796 times.
24358638 if(flags&guy_invisible)
4030 1573842 return;
4031
3/8
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 22758538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
22784796 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) && !(flags&lens_only))
4032 return;
4033
4034 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4035 // be cloaked if they have "invisible displays as cloaked" checked.
4036
4037 22784796 byte canSee = DRAW_NORMAL;
4038 //Enemy specific stuff
4039
1/2
✓ Branch 0 taken 22784796 times.
✗ Branch 1 not taken.
22784796 if ( editorflags & ENEMY_FLAG1 )
4040 {
4041 canSee = DRAW_INVIS;
4042 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4043 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4044 {
4045 if (game->item[dmisc13])
4046 {
4047 canSee = DRAW_NORMAL;
4048 }
4049 //else if ( lensclk && getlensid.flags SHOWINVIS )
4050 //{
4051 //
4052 //}
4053 //else
4054 //{
4055 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4056 // //otherwisem invisible
4057 //}
4058 }
4059 }
4060 //Room specific
4061
2/2
✓ Branch 0 taken 22592772 times.
✓ Branch 1 taken 192024 times.
22784796 if (tmpscr->flags3&fINVISROOM)
4062 {
4063
4/6
✓ Branch 0 taken 192024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33839 times.
✓ Branch 3 taken 158185 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33839 times.
225863 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33839 times.
33839 !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4065 192024 }
4066 //Lens check
4067
2/2
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 22758538 times.
22784796 if (lensclk)
4068 {
4069
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26258 if((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(flags&lens_only))
4070 {
4071 if (canSee == DRAW_NORMAL)
4072 {
4073 if (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) canSee = DRAW_CLOAKED;
4074 else canSee = DRAW_INVIS; //Should never happen cause dont_draw should catch this, but just in case.
4075 }
4076 }
4077
2/2
✓ Branch 0 taken 25826 times.
✓ Branch 1 taken 432 times.
26258 if(flags&lens_only)
4078 {
4079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4080 432 }
4081 26258 }
4082 else
4083 {
4084
2/2
✓ Branch 0 taken 22685122 times.
✓ Branch 1 taken 73416 times.
22758538 if(flags&lens_only)
4085 73416 canSee = DRAW_INVIS;
4086 }
4087
3/4
✓ Branch 0 taken 73416 times.
✓ Branch 1 taken 22711380 times.
✓ Branch 2 taken 73416 times.
✗ Branch 3 not taken.
22784796 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4088
3/4
✓ Branch 0 taken 22677541 times.
✓ Branch 1 taken 107255 times.
✓ Branch 2 taken 22677541 times.
✗ Branch 3 not taken.
22784796 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4089
4090
2/2
✓ Branch 0 taken 22711380 times.
✓ Branch 1 taken 73416 times.
22784796 if (canSee == DRAW_INVIS)
4091 73416 return;
4092
4093
3/4
✓ Branch 0 taken 22711238 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22711238 times.
22711380 if(fallclk||drownclk)
4094 {
4095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (canSee == DRAW_CLOAKED)
4096 {
4097 sprite::drawcloaked(dest);
4098 }
4099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if (canSee == DRAW_NORMAL)
4100 {
4101 142 sprite::draw(dest);
4102 142 }
4103 142 return;
4104 }
4105 22711238 int32_t cshold=cs;
4106
4107
2/2
✓ Branch 0 taken 531444 times.
✓ Branch 1 taken 22179794 times.
22711238 if(dying)
4108 {
4109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531444 times.
531444 if(clk2>=19)
4110 {
4111 if(!(clk2&2))
4112 {
4113 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4114 if (canSee == DRAW_CLOAKED)
4115 {
4116 sprite::drawcloaked(dest);
4117 }
4118 else if (canSee == DRAW_NORMAL)
4119 {
4120 sprite::draw(dest);
4121 }
4122 }
4123 return;
4124 }
4125
4126 531444 flip = 0;
4127 531444 tile = wpnsbuf[spr_death].tile;
4128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531444 times.
531444 if ( do_animation )
4129 {
4130 531444 int32_t offs = 0;
4131
2/2
✓ Branch 0 taken 526637 times.
✓ Branch 1 taken 4807 times.
531444 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4132 {
4133
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 239 times.
4807 if(clk2 > 2)
4134 {
4135 239 spr_death_anim_clk=0;
4136 239 clk2=1;
4137
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 235 times.
239 if(hp > -1000)
4138 235 death_sfx();
4139 239 }
4140
4/4
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4456 times.
4807 if(clk2==1 && spr_death_anim_clk>-1)
4141 {
4142 4456 ++clk2;
4143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
4456 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4144
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 4437 times.
4456 spr_death_anim_frm *= zc_max(1,txsz);
4145 4456 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4146
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 4382 times.
4456 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4147
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4456 times.
✓ Branch 4 taken 4217 times.
✓ Branch 5 taken 239 times.
4456 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4148 {
4149 239 spr_death_anim_clk=-1;
4150 239 clk2=1;
4151 239 }
4152 4456 }
4153 4807 tile += spr_death_anim_frm;
4154 4807 }
4155
2/2
✓ Branch 0 taken 79136 times.
✓ Branch 1 taken 447501 times.
526637 else if(BSZ)
4156 {
4157
2/2
✓ Branch 0 taken 62225 times.
✓ Branch 1 taken 16911 times.
79136 offs = zc_min((15-clk2)/3,4);
4158 79136 }
4159
4/4
✓ Branch 0 taken 298376 times.
✓ Branch 1 taken 149125 times.
✓ Branch 2 taken 149027 times.
✓ Branch 3 taken 149349 times.
447501 else if(clk2>6 && clk2<=12)
4160 {
4161 149349 offs = 1;
4162 149349 }
4163
4164
2/2
✓ Branch 0 taken 314434 times.
✓ Branch 1 taken 217010 times.
531444 if(offs)
4165 {
4166
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 216866 times.
217010 offs *= zc_max(1,txsz);
4167 217010 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4168
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 216866 times.
217010 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4169 217010 }
4170 531444 tile += offs;
4171 531444 }
4172
4173
6/6
✓ Branch 0 taken 526637 times.
✓ Branch 1 taken 4807 times.
✓ Branch 2 taken 447501 times.
✓ Branch 3 taken 79136 times.
✓ Branch 4 taken 129054 times.
✓ Branch 5 taken 318447 times.
531444 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4174 212997 cs = wpnsbuf[spr_death].csets&15;
4175 else
4176 318447 cs = (((clk2+5)>>1)&3)+6;
4177 531444 }
4178
3/4
✓ Branch 0 taken 662995 times.
✓ Branch 1 taken 21516799 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 662995 times.
22179794 else if(hclk>0 && getCanFlicker())
4179 {
4180 662995 cs = getFlashingCSet();
4181 662995 }
4182 //draw every other frame for flickering enemies
4183
2/2
✓ Branch 0 taken 137002 times.
✓ Branch 1 taken 22574236 times.
22711238 if (is_hitflickerframe(false))
4184 {
4185
5/6
✓ Branch 0 taken 46838 times.
✓ Branch 1 taken 90164 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 46837 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90165 times.
137002 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4186
2/4
✓ Branch 0 taken 137002 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 137002 times.
137002 if (game->get_spriteflickercolor() || temp_flicker_color)
4187 {
4188 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4189 sprite_flicker_color = temp_flicker_color;
4190 sprite::draw(dest);
4191 }
4192 137002 }
4193 else
4194 {
4195
2/2
✓ Branch 0 taken 33668 times.
✓ Branch 1 taken 22540568 times.
22574236 if (canSee == DRAW_CLOAKED)
4196 {
4197 33668 sprite::drawcloaked(dest);
4198 33668 }
4199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22540568 times.
22540568 else if (canSee == DRAW_NORMAL)
4200 {
4201
1/2
✓ Branch 0 taken 22540568 times.
✗ Branch 1 not taken.
22540568 if ( frozenclock < 0 )
4202 {
4203 if ( frozentile > 0 ) tile = frozentile;
4204 loadpalset(csBOSS,frozencset);
4205 }
4206 22540568 sprite::draw(dest);
4207 22540568 }
4208 }
4209 22711238 cs=cshold;
4210 24870233 }
4211
4212 //old zc bosses
4213 23264120 void enemy::drawzcboss(BITMAP *dest)
4214 {
4215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23264120 times.
23264120 if(dont_draw())
4216 return;
4217
4218 23264120 int32_t cshold=cs;
4219
4220
2/2
✓ Branch 0 taken 492438 times.
✓ Branch 1 taken 22771682 times.
23264120 if(dying)
4221 {
4222
2/2
✓ Branch 0 taken 2592 times.
✓ Branch 1 taken 489846 times.
492438 if(clk2>=19)
4223 {
4224
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 1296 times.
2592 if(!(clk2&2))
4225 1296 sprite::drawzcboss(dest);
4226
4227 2592 return;
4228 }
4229
4230 489846 flip = 0;
4231 489846 tile = wpnsbuf[spr_death].tile;
4232
4233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 489846 times.
489846 if ( do_animation )
4234 {
4235
2/2
✓ Branch 0 taken 487660 times.
✓ Branch 1 taken 2186 times.
489846 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4236 {
4237
2/2
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 2 times.
2186 if(clk2 > 2)
4238 {
4239 2 spr_death_anim_clk=0;
4240 2 clk2=1;
4241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(hp > -1000)
4242 2 death_sfx();
4243 2 }
4244
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 2 times.
2186 if(clk2==1 && spr_death_anim_clk>-1)
4245 {
4246 2 ++clk2;
4247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm *= zc_max(1,txsz);
4249 2 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4251
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4252 {
4253 spr_death_anim_clk=-1;
4254 clk2=1;
4255 }
4256 2 }
4257 2186 tile += spr_death_anim_frm;
4258 2186 }
4259
2/2
✓ Branch 0 taken 79248 times.
✓ Branch 1 taken 408412 times.
487660 else if(BSZ)
4260
2/2
✓ Branch 0 taken 62313 times.
✓ Branch 1 taken 16935 times.
79248 tile += zc_min((15-clk2)/3,4);
4261
4/4
✓ Branch 0 taken 272202 times.
✓ Branch 1 taken 136210 times.
✓ Branch 2 taken 135966 times.
✓ Branch 3 taken 136236 times.
408412 else if(clk2>6 && clk2<=12)
4262 136236 ++tile;
4263 489846 }
4264
4265
6/6
✓ Branch 0 taken 487660 times.
✓ Branch 1 taken 2186 times.
✓ Branch 2 taken 408412 times.
✓ Branch 3 taken 79248 times.
✓ Branch 4 taken 125904 times.
✓ Branch 5 taken 282508 times.
489846 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4266 207338 cs = wpnsbuf[spr_death].csets&15;
4267 else
4268 282508 cs = (((clk2+5)>>1)&3)+6;
4269 489846 }
4270
2/2
✓ Branch 0 taken 666510 times.
✓ Branch 1 taken 22105172 times.
22771682 else if(hclk>0)
4271 {
4272 666510 cs = getFlashingCSet();
4273 666510 }
4274
4275
3/4
✓ Branch 0 taken 167600 times.
✓ Branch 1 taken 23093928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2948 times.
23264476 if((tmpscr->flags3&fINVISROOM) &&
4276
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 164652 times.
167600 !(current_item(itype_amulet)) &&
4277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2948 times.
2948 !(get_qr(qr_LENSSEESENEMIES) &&
4278 2948 lensclk) && family!=eeGANON)
4279 {
4280 2948 sprite::drawcloaked(dest);
4281 2948 }
4282 else
4283 {
4284
2/2
✓ Branch 0 taken 15820 times.
✓ Branch 1 taken 23242760 times.
23258580 if (is_hitflickerframe(true))
4285 {
4286
4/6
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 15635 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 185 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15635 times.
15820 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4287
1/2
✓ Branch 0 taken 15820 times.
✗ Branch 1 not taken.
15820 if (game->get_spriteflickercolor())
4288 {
4289 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4290 sprite_flicker_color = temp_flicker_color;
4291 sprite::drawzcboss(dest);
4292 }
4293 15820 }
4294 else
4295 23242760 sprite::drawzcboss(dest);
4296 }
4297
4298 23261528 cs=cshold;
4299 23264120 }
4300
4301
4302 // similar to the overblock function--can do up to a 32x32 sprite
4303 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4304 136827 void enemy::drawblock(BITMAP *dest,int32_t mask)
4305 {
4306 136827 int32_t thold=tile;
4307 136827 int32_t t1=tile;
4308 136827 int32_t t2=tile+20;
4309 136827 int32_t t3=tile+1;
4310 136827 int32_t t4=tile+21;
4311
4312
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 136827 times.
136827 switch(mask)
4313 {
4314 case 1:
4315 enemy::drawzcboss(dest);
4316 break;
4317
4318 case 3:
4319 if(flip&2)
4320 zc_swap(t1,t2);
4321
4322 tile=t1;
4323 enemy::drawzcboss(dest);
4324 tile=t2;
4325 yofs+=16;
4326 enemy::drawzcboss(dest);
4327 yofs-=16;
4328 break;
4329
4330 case 5:
4331 t2=tile+1;
4332
4333 if(flip&1)
4334 zc_swap(t1,t2);
4335
4336 tile=t1;
4337 enemy::drawzcboss(dest);
4338 tile=t2;
4339 xofs+=16;
4340 enemy::drawzcboss(dest);
4341 xofs-=16;
4342 break;
4343
4344 case 15:
4345
2/2
✓ Branch 0 taken 130714 times.
✓ Branch 1 taken 6113 times.
136827 if(flip&1)
4346 {
4347 6113 zc_swap(t1,t3);
4348 6113 zc_swap(t2,t4);
4349 6113 }
4350
4351
1/2
✓ Branch 0 taken 136827 times.
✗ Branch 1 not taken.
136827 if(flip&2)
4352 {
4353 zc_swap(t1,t2);
4354 zc_swap(t3,t4);
4355 }
4356
4357 136827 tile=t1;
4358 136827 enemy::drawzcboss(dest);
4359 136827 tile=t2;
4360 136827 yofs+=16;
4361 136827 enemy::drawzcboss(dest);
4362 136827 yofs-=16;
4363 136827 tile=t3;
4364 136827 xofs+=16;
4365 136827 enemy::drawzcboss(dest);
4366 136827 tile=t4;
4367 136827 yofs+=16;
4368 136827 enemy::drawzcboss(dest);
4369 136827 xofs-=16;
4370 136827 yofs-=16;
4371 136827 break;
4372 }
4373
4374 136827 tile=thold;
4375 136827 }
4376
4377 5845877 void enemy::drawshadow(BITMAP *dest, bool translucent)
4378 {
4379
4/4
✓ Branch 0 taken 5415173 times.
✓ Branch 1 taken 430704 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 5009084 times.
5845877 if(dont_draw() || isSideViewGravity())
4380 {
4381 836793 return;
4382 }
4383
4384
2/2
✓ Branch 0 taken 80005 times.
✓ Branch 1 taken 4929079 times.
5009084 if(dying)
4385 {
4386 80005 return;
4387 }
4388
4389
4/4
✓ Branch 0 taken 2116 times.
✓ Branch 1 taken 4926963 times.
✓ Branch 2 taken 147668 times.
✓ Branch 3 taken 4781411 times.
4929079 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4390 4929079 (darkroom))
4391 {
4392 147668 return;
4393 }
4394 else
4395 {
4396
4/4
✓ Branch 0 taken 4563880 times.
✓ Branch 1 taken 217531 times.
✓ Branch 2 taken 4551272 times.
✓ Branch 3 taken 12608 times.
4781411 if(enemycanfall(id, false) && shadowtile == 0)
4397 12608 shadowtile = wpnsbuf[spr_shadow].tile;
4398
4399
5/6
✓ Branch 0 taken 4209361 times.
✓ Branch 1 taken 572050 times.
✓ Branch 2 taken 4209361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3991830 times.
✓ Branch 5 taken 217531 times.
4781411 if(z>0 || fakez>0 || !enemycanfall(id, false))
4400 {
4401
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 789465 times.
789581 if(!shadow_overpit(this))
4402 789465 sprite::drawshadow(dest,translucent);
4403 789581 }
4404 }
4405 5845877 }
4406
4407 88213 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4408 {
4409 88213 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4410
4411
1/2
✓ Branch 0 taken 88213 times.
✗ Branch 1 not taken.
88213 if(sub!=NULL)
4412 {
4413 88213 xofs-=mx;
4414 88213 yofs-=my;
4415 88213 enemy::draw(sub);
4416 88213 xofs+=mx;
4417 88213 yofs+=my;
4418 88213 destroy_bitmap(sub);
4419 88213 }
4420 else
4421 enemy::draw(dest);
4422 88213 }
4423
4424 // override hit detection to check for invicibility, stunned, etc
4425 66872480 bool enemy::hit()
4426 {
4427
4/4
✓ Branch 0 taken 66047727 times.
✓ Branch 1 taken 824753 times.
✓ Branch 2 taken 64960106 times.
✓ Branch 3 taken 1087621 times.
66872480 if(dying || hclk>0) return false;
4428 64960106 return sprite::hit();
4429 66872480 }
4430 52704 bool enemy::hit(sprite *s)
4431 {
4432
3/4
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52264 times.
✓ Branch 3 taken 440 times.
52704 if(!hit() || !s->hit()) return false;
4433 52264 return sprite::hit(s);
4434 52704 }
4435
4436 27517195 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4437 {
4438
2/2
✓ Branch 0 taken 2179304 times.
✓ Branch 1 taken 25337891 times.
27517195 if(!hit()) return false;
4439 25337891 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4440 27517195 }
4441 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4442 {
4443 if(!hit()) return false;
4444 return sprite::hit(tx,ty,txsz2,tysz2);
4445 }
4446
4447 7434715 bool enemy::hit(weapon *w)
4448 {
4449
2/2
✓ Branch 0 taken 851646 times.
✓ Branch 1 taken 6583069 times.
7434715 if(!hit()) return false;
4450
4451
2/2
✓ Branch 0 taken 6581733 times.
✓ Branch 1 taken 1336 times.
6583069 if (replay_version_check(0, 14))
4452 {
4453
4/6
✓ Branch 0 taken 6361773 times.
✓ Branch 1 taken 219960 times.
✓ Branch 2 taken 6361773 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6361773 times.
✗ Branch 5 not taken.
6581733 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk)
4454 219960 return false;
4455 6361773 return sprite::hit(w);
4456 }
4457 1336 return w->hit(this);
4458 7434715 }
4459
4460 6078176 bool enemy::can_pitfall(bool checkspawning)
4461 {
4462
4/4
✓ Branch 0 taken 6070221 times.
✓ Branch 1 taken 7955 times.
✓ Branch 2 taken 6068385 times.
✓ Branch 3 taken 9791 times.
6078176 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4463
2/2
✓ Branch 0 taken 6060917 times.
✓ Branch 1 taken 7468 times.
6068385 switch(guysbuf[id&0xFFF].family)
4464 {
4465 case eeAQUA:
4466 case eeDIG:
4467 case eeDONGO:
4468 case eeFAIRY:
4469 case eeGANON:
4470 case eeGHOMA:
4471 case eeGLEEOK:
4472 case eeGUY:
4473 case eeLANM:
4474 case eeMANHAN:
4475 case eeMOLD:
4476 case eeNONE:
4477 case eePATRA:
4478 case eeZORA:
4479 7468 return false; //Disallowed types
4480 default:
4481 6060917 return true;
4482 }
4483 6078176 }
4484 //Handle death
4485 21148622 void enemy::try_death(bool force_kill)
4486 {
4487
8/8
✓ Branch 0 taken 21107695 times.
✓ Branch 1 taken 40927 times.
✓ Branch 2 taken 21107693 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 24644 times.
✓ Branch 5 taken 21083049 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 24643 times.
21148622 if(!dying && (force_kill || (hp<=0 && !immortal)))
4488 {
4489 24645 std::vector<int32_t> &ev = FFCore.eventData;
4490 24645 ev.clear();
4491 24645 ev.push_back(10000);
4492 24645 ev.push_back(getUID());
4493
4494 24645 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4495 24645 bool isSaved = !ev[0];
4496 24645 ev.clear();
4497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24645 times.
24645 if(isSaved) return;
4498
4499
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24621 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 22 times.
24645 if(itemguy && (hasitem&2)!=0)
4500 {
4501
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 22 times.
47 for(int32_t i=0; i<items.Count(); i++)
4502 {
4503
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 22 times.
25 if(((item*)items.spr(i))->pickup&ipENEMY)
4504 {
4505
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4506 {
4507 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4508 {
4509 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4510 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4511 }
4512 else
4513 {
4514 if(extend >= 3)
4515 {
4516 items.spr(i)->x = x+(txsz-1)*8;
4517 items.spr(i)->y = y-2+(tysz-1)*8;
4518 }
4519 else
4520 {
4521 items.spr(i)->x = x;
4522 items.spr(i)->y = y - 2;
4523 }
4524 }
4525 items.spr(i)->z = z;
4526 items.spr(i)->fakez = fakez;
4527 }
4528 else
4529 {
4530 22 items.spr(i)->x = x;
4531 22 items.spr(i)->y = y - 2;
4532 }
4533 22 }
4534 25 }
4535 22 }
4536
4537 24645 dying=true;
4538
4539
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 24623 times.
24645 if(fading==fade_flash_die)
4540 22 clk2=19+18*4;
4541 else
4542 {
4543 24623 clk2 = BSZ ? 15 : 19;
4544
4545
2/2
✓ Branch 0 taken 6674 times.
✓ Branch 1 taken 17949 times.
24623 if(fading!=fade_blue_poof)
4546 17949 fading=0;
4547 }
4548
4549
2/2
✓ Branch 0 taken 24621 times.
✓ Branch 1 taken 24 times.
24645 if(itemguy)
4550 {
4551 24 hasitem&=~2;
4552 24 item_set=0;
4553 24 }
4554
4555
6/6
✓ Branch 0 taken 23961 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 19569 times.
✓ Branch 3 taken 4392 times.
✓ Branch 4 taken 644 times.
✓ Branch 5 taken 18925 times.
24645 if(currscr<128 && count_enemy && !script_spawned)
4556 18925 game->guys[(currmap<<7)+currscr]-=1;
4557 24645 }
4558 21148622 }
4559
4560 // --==**==--
4561
4562 // Movement routines that can be used by derived classes as needed
4563
4564 // --==**==--
4565
4566 324351 void enemy::fix_coords(bool bound)
4567 {
4568
1/2
✓ Branch 0 taken 324351 times.
✗ Branch 1 not taken.
324351 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4569
1/2
✓ Branch 0 taken 324351 times.
✗ Branch 1 not taken.
324351 if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false;
4570
4571
4572
2/2
✓ Branch 0 taken 41509 times.
✓ Branch 1 taken 282842 times.
324351 if(bound)
4573 {
4574
1/2
✓ Branch 0 taken 282842 times.
✗ Branch 1 not taken.
282842 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4575 {
4576
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282842 x=vbound(x, 0_zf, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256_zf -((txsz-1)*16)) : 240_zf));
4577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282842 y=vbound(y, 0_zf,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176_zf -((txsz-1)*16)) : 160_zf));
4578 282842 }
4579 else
4580 {
4581 x=vbound(x, 0_zf,240_zf);
4582 y=vbound(y, 0_zf,160_zf);
4583 }
4584 282842 }
4585
4586
6/10
✓ Branch 0 taken 323337 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 324351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 324351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 324351 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 324351 times.
324351 if(!OUTOFBOUNDS)
4587 {
4588 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
4589
4590 if(isSideViewGravity())
4591 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
4592 else
4593 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
4594 */
4595 324351 do_fix(x, 16, true);
4596
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 323337 times.
324351 if(isSideViewGravity())
4597 1014 do_fix(y,8,true);
4598 323337 else do_fix(y,16,true);
4599 324351 }
4600 324351 }
4601 6036 bool enemy::cannotpenetrate()
4602 {
4603
4/4
✓ Branch 0 taken 5919 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 5900 times.
6036 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4604 }
4605
4606 394 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4607 {
4608 bool ok;
4609 394 int32_t dx = 0, dy = 0;
4610 394 int32_t sv = 8;
4611
4612 //Why is this here??? Why is it needed???
4613 394 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4614
4615
8/9
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 66 times.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 43 times.
✓ Branch 7 taken 56 times.
✗ Branch 8 not taken.
394 switch(ndir)
4616 {
4617 case 8:
4618 case up:
4619
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
44 if(canfall(id) && isSideViewGravity())
4620 return false;
4621
4622 44 dy = dy1-s;
4623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 special = (special==spw_clipbottomright)?spw_none:special;
4624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4625 44 break;
4626
4627 case 12:
4628 case down:
4629
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
40 if(canfall(id) && isSideViewGravity())
4630 return false;
4631
4632 40 dy = dy2+s;
4633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4634 40 break;
4635
4636 case 14:
4637 case left:
4638 34 dx = dx1-s;
4639 34 sv = ((isSideViewGravity())?7:8);
4640
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4641
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 33 times.
34 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4642 34 break;
4643
4644 case 10:
4645 case right:
4646 55 dx = dx2+s;
4647 55 sv = ((isSideViewGravity())?7:8);
4648
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 50 times.
55 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4649 55 break;
4650
4651 case 9:
4652 case r_up:
4653 66 dx = dx2+s;
4654 66 dy = dy1-s;
4655
3/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 1 times.
131 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4657 66 break;
4658
4659 case 11:
4660 case r_down:
4661 56 dx = dx2+s;
4662 56 dx = dy2+s;
4663
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4665 56 break;
4666
4667 case 13:
4668 case l_down:
4669 43 dx = dx1-s;
4670 43 dy = dy2+s;
4671
3/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
84 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4673 43 break;
4674
4675 case 15:
4676 case l_up:
4677 56 dx = dx1-s;
4678 56 dy = dy1-s;
4679
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4681 56 break;
4682
4683 default:
4684 db=99;
4685 return true;
4686 }
4687
4688 394 return ok;
4689 394 }
4690
4691
4692
4693
4694 // returns true if next step is ok, false if there is something there
4695 3806334 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4696 {
4697 3806334 bool ok = false; //initialise the var, son't just declare it
4698 3806334 int32_t dx = 0, dy = 0;
4699 3806334 int32_t sv = 8;
4700 3806334 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4701 //Why is this here??? Why is it needed???
4702 3806334 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4707 3806334 bool offgrid = OFFGRID_ENEMY;
4708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 if(!offgrid)
4709 {
4710 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4711
1/2
✓ Branch 0 taken 3806334 times.
✗ Branch 1 not taken.
3806334 if(usehei<16)usehei=16;
4712
1/2
✓ Branch 0 taken 3806334 times.
✗ Branch 1 not taken.
3806334 if(usewid<16)usewid=16;
4713 3806334 }
4714
9/9
✓ Branch 0 taken 708846 times.
✓ Branch 1 taken 565128 times.
✓ Branch 2 taken 629158 times.
✓ Branch 3 taken 634154 times.
✓ Branch 4 taken 290259 times.
✓ Branch 5 taken 347714 times.
✓ Branch 6 taken 321027 times.
✓ Branch 7 taken 306379 times.
✓ Branch 8 taken 3669 times.
3806334 switch(ndir) //need to check every 8 pixels between two points
4715 {
4716 case 8:
4717 case up:
4718 {
4719
4/4
✓ Branch 0 taken 96582 times.
✓ Branch 1 taken 612264 times.
✓ Branch 2 taken 95992 times.
✓ Branch 3 taken 590 times.
708846 if(enemycanfall(id) && isSideViewGravity())
4720 590 return false;
4721
4722 708256 dy = dy1-s;
4723
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 708253 times.
708256 special = (special==spw_clipbottomright)?spw_none:special;
4724 708256 tries = usewid/(offgrid ? 8 : 16);
4725 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4726
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 708256 times.
1316075 for ( ; tries > 0; --tries )
4727 {
4728
2/2
✓ Branch 0 taken 98395 times.
✓ Branch 1 taken 609861 times.
708256 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4729 708256 try_x += (offgrid ? 8 : 16);
4730
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 100437 times.
708256 if (!ok) break;
4731 607819 }
4732
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 100437 times.
708256 if(!ok) break;
4733
1/2
✓ Branch 0 taken 607819 times.
✗ Branch 1 not taken.
607819 if((usewid%16)>0) //Uneven width
4734 {
4735 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4736 }
4737 607819 break;
4738 }
4739 case 12:
4740 case down:
4741 {
4742
4/4
✓ Branch 0 taken 107028 times.
✓ Branch 1 taken 458100 times.
✓ Branch 2 taken 106340 times.
✓ Branch 3 taken 688 times.
565128 if(enemycanfall(id) && isSideViewGravity())
4743 688 return false;
4744
4745 564440 dy = dy2+s;
4746 564440 tries = usewid/(offgrid ? 8 : 16);
4747 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4748
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 564440 times.
1025090 for ( ; tries > 0; --tries )
4749 {
4750
3/4
✓ Branch 0 taken 103361 times.
✓ Branch 1 taken 461079 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 461079 times.
564440 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4751 564440 try_x += (offgrid ? 8 : 16);
4752
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 103790 times.
564440 if (!ok) break;
4753 460650 }
4754
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 103790 times.
564440 if(!ok) break;
4755
1/2
✓ Branch 0 taken 460650 times.
✗ Branch 1 not taken.
460650 if((usewid%16)>0) //Uneven width
4756 {
4757 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4758 }
4759 460650 break;
4760 }
4761 case 14:
4762 case left:
4763 {
4764 629158 dx = dx1-s;
4765 629158 sv = ((isSideViewGravity())?7:0);
4766
4/4
✓ Branch 0 taken 629152 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1272 times.
✓ Branch 3 taken 627880 times.
629158 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4767 629158 tries = usehei/(offgrid ? 8 : 16);
4768 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4769
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 629158 times.
1161818 for ( ; tries > 0; --tries )
4770 {
4771
2/2
✓ Branch 0 taken 95665 times.
✓ Branch 1 taken 533493 times.
629158 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4772 629158 try_y += (offgrid ? 8 : 16);
4773
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 96498 times.
629158 if (!ok) break;
4774 532660 }
4775
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 96498 times.
629158 if(!ok) break;
4776
1/2
✓ Branch 0 taken 532660 times.
✗ Branch 1 not taken.
532660 if((usehei%16)>0) //Uneven height
4777 {
4778 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4779 }
4780 532660 break;
4781 }
4782 case 10:
4783 case right:
4784 {
4785 634154 dx = dx2+s;
4786 634154 sv = ((isSideViewGravity())?7:0);
4787 634154 tries = usehei/(offgrid ? 8 : 16);
4788 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4789
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 634154 times.
1174344 for ( ; tries > 0; --tries )
4790 {
4791
3/4
✓ Branch 0 taken 93176 times.
✓ Branch 1 taken 540978 times.
✓ Branch 2 taken 540978 times.
✗ Branch 3 not taken.
634154 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4792 634154 try_y += (offgrid ? 8 : 16);
4793
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 93964 times.
634154 if (!ok) break;
4794 540190 }
4795
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 93964 times.
634154 if(!ok) break;
4796
1/2
✓ Branch 0 taken 540190 times.
✗ Branch 1 not taken.
540190 if((usehei%16)>0) //Uneven height
4797 {
4798 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4799 }
4800 540190 break;
4801 }
4802 case 9:
4803 case r_up:
4804 {
4805 290259 dx = dx2+s;
4806 290259 dy = dy1-s;
4807 290259 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4808 290259 sv = ((isSideViewGravity())?7:0);
4809
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 290259 times.
571093 for ( ; tries_x > 0; --tries_x )
4810 {
4811 290259 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4812 290259 try_y = 0;
4813
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 290259 times.
571093 for ( ; tries_y > 0; --tries_y )
4814 {
4815
4/4
✓ Branch 0 taken 286282 times.
✓ Branch 1 taken 3977 times.
✓ Branch 2 taken 283302 times.
✓ Branch 3 taken 2980 times.
573561 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4816
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 281502 times.
283302 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4817 290259 try_y += (offgrid ? 8 : 16);
4818
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if (!ok) break;
4819 280834 }
4820
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if (!ok) break;
4821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280834 times.
280834 if((usehei%16)>0) //Uneven height
4822 {
4823 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4824 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4825 }
4826 280834 try_x += (offgrid ? 8 : 16);
4827 280834 }
4828
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if(!ok) break;
4829
1/2
✓ Branch 0 taken 280834 times.
✗ Branch 1 not taken.
280834 if((usewid%16)>0) //Uneven width
4830 {
4831 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4832 try_y = 0;
4833 for ( ; tries_y > 0; --tries_y )
4834 {
4835 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4836 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4837 try_y += (offgrid ? 8 : 16);
4838 if (!ok) break;
4839 }
4840 if (!ok) break;
4841 if((usehei%16)>0) //Uneven height
4842 {
4843 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4844 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4845 }
4846 }
4847 280834 break;
4848 }
4849 case 11:
4850 case r_down:
4851 {
4852 347714 dx = dx2+s;
4853 347714 dx = dy2+s;
4854 347714 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4855 //sv = ((isSideViewGravity())?7:0);
4856
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 347714 times.
687537 for ( ; tries_x > 0; --tries_x )
4857 {
4858 347714 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4859 347714 try_y = 0;
4860
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 347714 times.
687537 for ( ; tries_y > 0; --tries_y )
4861 {
4862
4/4
✓ Branch 0 taken 347575 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 340363 times.
✓ Branch 3 taken 7212 times.
688077 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4863
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 340321 times.
340363 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4864 347714 try_y += (offgrid ? 8 : 16);
4865
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if (!ok) break;
4866 339823 }
4867
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if (!ok) break;
4868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339823 times.
339823 if((usehei%16)>0) //Uneven height
4869 {
4870 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4871 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4872 }
4873 339823 try_x += (offgrid ? 8 : 16);
4874 339823 }
4875
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if(!ok) break;
4876
1/2
✓ Branch 0 taken 339823 times.
✗ Branch 1 not taken.
339823 if((usewid%16)>0) //Uneven width
4877 {
4878 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4879 try_y = 0;
4880 for ( ; tries_y > 0; --tries_y )
4881 {
4882 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4883 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4884 try_y += (offgrid ? 8 : 16);
4885 if (!ok) break;
4886 }
4887 if (!ok) break;
4888 if((usehei%16)>0) //Uneven height
4889 {
4890 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4891 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4892 }
4893 }
4894 339823 break;
4895 }
4896 case 13:
4897 case l_down:
4898 {
4899 321027 dx = dx1-s;
4900 321027 dy = dy2+s;
4901 321027 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4902 //sv = ((isSideViewGravity())?7:0);
4903
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 321027 times.
633935 for ( ; tries_x > 0; --tries_x )
4904 {
4905 321027 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4906 321027 try_y = 0;
4907
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 321027 times.
633935 for ( ; tries_y > 0; --tries_y )
4908 {
4909
4/4
✓ Branch 0 taken 315731 times.
✓ Branch 1 taken 5296 times.
✓ Branch 2 taken 313353 times.
✓ Branch 3 taken 2378 times.
634380 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4910
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 313025 times.
313353 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4911 321027 try_y += (offgrid ? 8 : 16);
4912
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if (!ok) break;
4913 312908 }
4914
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if (!ok) break;
4915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312908 times.
312908 if((usehei%16)>0) //Uneven height
4916 {
4917 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4918 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4919 }
4920 312908 try_x += (offgrid ? 8 : 16);
4921 312908 }
4922
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if(!ok) break;
4923
1/2
✓ Branch 0 taken 312908 times.
✗ Branch 1 not taken.
312908 if((usewid%16)>0) //Uneven width
4924 {
4925 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4926 try_y = 0;
4927 for ( ; tries_y > 0; --tries_y )
4928 {
4929 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4930 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4931 try_y += (offgrid ? 8 : 16);
4932 if (!ok) break;
4933 }
4934 if (!ok) break;
4935 if((usehei%16)>0) //Uneven height
4936 {
4937 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4938 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4939 }
4940 }
4941 312908 break;
4942 }
4943 case 15:
4944 case l_up:
4945 {
4946 306379 dx = dx1-s;
4947 306379 dy = dy1-s;
4948 306379 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4949 306379 sv = ((isSideViewGravity())?7:0);
4950
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 306379 times.
603796 for ( ; tries_x > 0; --tries_x )
4951 {
4952 306379 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4953 306379 try_y = 0;
4954
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 306379 times.
603796 for ( ; tries_y > 0; --tries_y )
4955 {
4956
4/4
✓ Branch 0 taken 302185 times.
✓ Branch 1 taken 4194 times.
✓ Branch 2 taken 299965 times.
✓ Branch 3 taken 2220 times.
606344 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4957
2/2
✓ Branch 0 taken 1918 times.
✓ Branch 1 taken 298047 times.
299965 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4958 306379 try_y += (offgrid ? 8 : 16);
4959
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if (!ok) break;
4960 297417 }
4961
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if (!ok) break;
4962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297417 times.
297417 if((usehei%16)>0) //Uneven height
4963 {
4964 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4965 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4966 }
4967 297417 try_x += (offgrid ? 8 : 16);
4968 297417 }
4969
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if(!ok) break;
4970
1/2
✓ Branch 0 taken 297417 times.
✗ Branch 1 not taken.
297417 if((usewid%16)>0) //Uneven width
4971 {
4972 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4973 try_y = 0;
4974 for ( ; tries_y > 0; --tries_y )
4975 {
4976 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4977 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4978 try_y += (offgrid ? 8 : 16);
4979 if (!ok) break;
4980 }
4981 if (!ok) break;
4982 if((usehei%16)>0) //Uneven height
4983 {
4984 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4985 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4986 }
4987 }
4988 297417 break;
4989 }
4990 default:
4991 3669 db=99;
4992 3669 return true;
4993 }
4994 //Z_eventlog("\n");
4995 3801387 return ok;
4996 3806334 }
4997
4998
4999 2471516 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
5000 {
5001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2471516 times.
2471516 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
5002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2471516 times.
2471516 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5003
1/2
✓ Branch 0 taken 2471516 times.
✗ Branch 1 not taken.
2471516 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5004
1/2
✓ Branch 0 taken 2471516 times.
✗ Branch 1 not taken.
2471516 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5005 2471516 --usewid;
5006 2471516 --usehei;
5007 2471516 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
5008 }
5009
5010 663823 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5011 {
5012 663823 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5013
5014
4/4
✓ Branch 0 taken 4788 times.
✓ Branch 1 taken 659035 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 1192 times.
663823 if(special==spw_clipright&&ndir==right)
5015 {
5016 1192 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5017 1192 }
5018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663823 times.
663823 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
5019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663823 times.
663823 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5020
1/2
✓ Branch 0 taken 663823 times.
✗ Branch 1 not taken.
663823 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5021
1/2
✓ Branch 0 taken 663823 times.
✗ Branch 1 not taken.
663823 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5022 663823 --usewid;
5023 663823 --usehei;
5024
2/2
✓ Branch 0 taken 357484 times.
✓ Branch 1 taken 306339 times.
663823 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5025 }
5026
5027 65432 bool enemy::canmove(int32_t ndir, bool kb)
5028 {
5029 65432 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5030 }
5031
5032 // 8-directional
5033 394 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5034 {
5035 394 int32_t ndir=0;
5036
5037 // can move straight, check if it wants to turn
5038
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 9 times.
394 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5039 {
5040
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5041 {
5042 int32_t w = Lwpns.idFirst(wBait);
5043
5044 if(w>=0)
5045 {
5046 int32_t bx = Lwpns.spr(w)->x;
5047 int32_t by = Lwpns.spr(w)->y;
5048
5049 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5050
5051 if(abs(int32_t(y)-by)>14)
5052 {
5053 if(ndir>0) // Already left or right
5054 {
5055 // Making the diagonal directions
5056 ndir += (by<y) ? 2 : 4;
5057 }
5058 else
5059 {
5060 ndir = (by<y) ? up : down;
5061 }
5062 }
5063
5064 if(canmove(ndir,special,false))
5065 {
5066 dir=ndir;
5067 return;
5068 }
5069 }
5070 }
5071
5072 // Homing added.
5073
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if(newhoming && (zc_oldrand()&255)<newhoming)
5074 {
5075 ndir = lined_up(8,true);
5076
5077 if(ndir>=0 && canmove(ndir,special,false))
5078 {
5079 dir=ndir;
5080 }
5081
5082 return;
5083 }
5084
5085 385 int32_t r=zc_oldrand();
5086
5087
2/4
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
385 if(newrate>0 && !(r%newrate))
5088 {
5089 385 ndir = ((dir+((r&64)?-1:1))&7)+8;
5090 385 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5091
5092
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 14 times.
385 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5093 371 dir=ndir;
5094
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
14 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5095 11 dir=ndir2;
5096
5097
3/4
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 371 times.
✗ Branch 3 not taken.
385 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5098 // due to numerous lost fractional components. -L
5099 {
5100 x.doFloor();
5101 y.doFloor();
5102 }
5103 385 }
5104
5105 385 return;
5106 }
5107
5108 // can't move straight, must turn
5109 9 int32_t i=0;
5110
5111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 for(; i<32; i++) // Try random dir
5112 {
5113 16 ndir=(zc_oldrand()&7)+8;
5114
5115
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9 times.
16 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5116 9 break;
5117 7 }
5118
5119
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(i==32)
5120 {
5121 for(ndir=8; ndir<16; ndir++)
5122 {
5123 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5124 goto ok;
5125 }
5126
5127 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5128 }
5129
5130 ok:
5131 9 dir=ndir;
5132 9 x.doFloor();
5133 9 y.doFloor();
5134 394 }
5135
5136 311413 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5137 {
5138 311413 int32_t ndir=0;
5139
5140 // can move straight, check if it wants to turn
5141
2/2
✓ Branch 0 taken 293564 times.
✓ Branch 1 taken 17849 times.
311413 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5142 {
5143
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 293357 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
293564 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5144 {
5145 101 int32_t i = Lwpns.idFirst(wBait);
5146
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5147 {
5148 weapon *w = (weapon*)Lwpns.spr(i);
5149 if (get_qr(qr_FIND_CLOSEST_BAIT))
5150 {
5151 int32_t currentrange;
5152 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5153 else currentrange = -1;
5154 int curid = i;
5155 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5156 for(; i<Lwpns.Count(); ++i)
5157 {
5158 weapon *lw = (weapon*)Lwpns.spr(i);
5159 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5160 {
5161 currentrange = distance(x, y, lw->x, lw->y);
5162 curid = i;
5163 }
5164 }
5165 i = curid;
5166 if (currentrange == -1) i = -1;
5167 }
5168 else
5169 {
5170 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5171 }
5172 if(i>=0)
5173 {
5174 int32_t bx = Lwpns.spr(i)->x;
5175 int32_t by = Lwpns.spr(i)->y;
5176
5177 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5178
5179 if(abs(int32_t(y)-by)>14)
5180 {
5181 if(ndir>0) // Already left or right
5182 {
5183 // Making the diagonal directions
5184 ndir += (by<y) ? 2 : 4;
5185 }
5186 else
5187 {
5188 ndir = (by<y) ? up : down;
5189 }
5190 }
5191 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5192 if(canmove(ndir,special,false))
5193 {
5194 dir=ndir;
5195 return;
5196 }
5197 }
5198 }
5199 101 }
5200
5201 // Homing added.
5202
4/4
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 292999 times.
✓ Branch 2 taken 409 times.
✓ Branch 3 taken 156 times.
293564 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5203 {
5204 156 ndir = lined_up(8,true);
5205
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
156 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5206
4/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 87 times.
156 if(ndir>=0 && canmove(ndir,special,false))
5207 {
5208 87 dir=ndir;
5209 87 }
5210
5211 156 return;
5212 }
5213
5214 293408 int32_t r=zc_oldrand();
5215
5216
4/4
✓ Branch 0 taken 184141 times.
✓ Branch 1 taken 109267 times.
✓ Branch 2 taken 99386 times.
✓ Branch 3 taken 84755 times.
293408 if(newrate>0 && !(r%newrate))
5217 {
5218 84755 ndir = ((dir+((r&64)?-1:1))&7)+8;
5219 84755 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5220
5221
2/2
✓ Branch 0 taken 81873 times.
✓ Branch 1 taken 2882 times.
84755 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5222 81873 dir=ndir;
5223
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 2702 times.
2882 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5224 2702 dir=ndir2;
5225
5226
4/4
✓ Branch 0 taken 81873 times.
✓ Branch 1 taken 2882 times.
✓ Branch 2 taken 77990 times.
✓ Branch 3 taken 3883 times.
84755 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5227 // due to numerous lost fractional components. -L
5228 {
5229 3883 x.doFloor();
5230 3883 y.doFloor();
5231 3883 }
5232 84755 }
5233
5234 293408 return;
5235 }
5236
5237 // can't move straight, must turn
5238 17849 int32_t i=0;
5239
5240
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 33819 times.
33847 for(; i<32; i++) // Try random dir
5241 {
5242 33819 ndir=(zc_oldrand()&7)+8;
5243
5244
2/2
✓ Branch 0 taken 15998 times.
✓ Branch 1 taken 17821 times.
33819 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5245 17821 break;
5246 15998 }
5247
5248
2/2
✓ Branch 0 taken 17821 times.
✓ Branch 1 taken 28 times.
17866 if(i==32)
5249 {
5250
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 17 times.
172 for(ndir=8; ndir<16; ndir++)
5251 {
5252
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 11 times.
155 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5253 11 goto ok;
5254 144 }
5255
5256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5257 17 }
5258
5259 ok:
5260 17849 dir=ndir;
5261 17849 x.doFloor();
5262 17849 y.doFloor();
5263 311413 }
5264
5265 307935 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5266 {
5267 307935 newdir_8(newrate,newhoming,special,0,-8,15,15);
5268 307935 }
5269
5270 394 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5271 {
5272 394 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5273 394 }
5274
5275 // makes the enemy slide backwards when hit
5276 // sclk: first byte is clk, second byte is dir
5277 // makes the enemy slide backwards when hit
5278 // sclk: first byte is clk, second byte is dir
5279 9376002 int32_t enemy::slide()
5280 {
5281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9376002 times.
9376002 if(script_knockback_clk!=0) //scripted knockback
5282 {
5283 sclk = 0;
5284 return 1; //scripted knockback ran
5285 }
5286
5/6
✓ Branch 0 taken 55775 times.
✓ Branch 1 taken 9320227 times.
✓ Branch 2 taken 5384 times.
✓ Branch 3 taken 50391 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5384 times.
9376002 if(sclk==0 || (hp<=0 && !immortal))
5287 9325611 return 0;
5288
5289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50391 times.
50391 if(knockbackflags & FLAG_NOSLIDE)
5290 {
5291 sclk = 0;
5292 if(!OFFGRID_ENEMY)
5293 {
5294 //Fix to grid
5295 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
5296 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
5297 do_fix(x, 16, true);
5298 do_fix(y, 16, true);
5299 }
5300 return 0;
5301 }
5302
8/10
✓ Branch 0 taken 5089 times.
✓ Branch 1 taken 45302 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 5064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 3796 times.
✓ Branch 7 taken 1268 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
50391 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5303 {
5304 1268 sclk=0;
5305 1268 return 0;
5306 }
5307
5308 49123 --sclk;
5309
5310
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 6052 times.
✓ Branch 2 taken 6364 times.
✓ Branch 3 taken 16287 times.
✓ Branch 4 taken 18763 times.
49123 switch(sclk>>8)
5311 {
5312 case up:
5313 {
5314
4/4
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 5378 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6046 times.
6052 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5315 {
5316 6 sclk=0;
5317 6 return 0;
5318 }
5319
4/4
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 5372 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 110 times.
6046 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5320
5321 5936 break;
5322 }
5323 case down:
5324 {
5325
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6362 times.
6364 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5326 {
5327 2 sclk=0;
5328 2 return 0;
5329 }
5330
4/4
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 5593 times.
✓ Branch 2 taken 668 times.
✓ Branch 3 taken 101 times.
6362 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5331
5332 6261 break;
5333 }
5334 case left:
5335 {
5336
4/4
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 14874 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 16274 times.
16287 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5337 {
5338 13 sclk=0;
5339 13 return 0;
5340 }
5341
4/4
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 14861 times.
✓ Branch 2 taken 1295 times.
✓ Branch 3 taken 118 times.
16274 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5342
5343 16156 break;
5344 }
5345 case right:
5346 {
5347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18763 times.
18763 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5348 {
5349 sclk=0;
5350 return 0;
5351 }
5352
4/4
✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 16402 times.
✓ Branch 2 taken 2195 times.
✓ Branch 3 taken 166 times.
18763 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5353 18597 break;
5354 }
5355 }
5356
5357 48607 int32_t move = knockbackSpeed;
5358
2/2
✓ Branch 0 taken 46088 times.
✓ Branch 1 taken 48607 times.
94695 while(move>0)
5359 {
5360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48607 times.
48607 int32_t thismove = zc_min(8, move);
5361 48607 move -= thismove;
5362 48607 hitdir = (sclk>>8);
5363
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 5936 times.
✓ Branch 2 taken 6261 times.
✓ Branch 3 taken 16156 times.
✓ Branch 4 taken 18597 times.
48607 switch(sclk>>8)
5364 {
5365 case up:
5366 5936 y-=thismove;
5367 5936 break;
5368
5369 case down:
5370 6261 y+=thismove;
5371 6261 break;
5372
5373 case left:
5374 16156 x-=thismove;
5375 16156 break;
5376
5377 case right:
5378 18597 x+=thismove;
5379 18597 break;
5380 }
5381
2/2
✓ Branch 0 taken 46088 times.
✓ Branch 1 taken 2519 times.
48607 if(!canmove(sclk>>8,(zfix)0,0,true))
5382 {
5383
3/3
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 1460 times.
✓ Branch 2 taken 4 times.
2519 switch(sclk>>8)
5384 {
5385 case up:
5386 case down:
5387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1055 times.
1055 if(y < 0)
5388 y = 0;
5389
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 865 times.
1055 else if((int32_t(y)&15) > 7)
5390 190 y=(int32_t(y)&0xF0)+16;
5391 else
5392 865 y=(int32_t(y)&0xF0);
5393
5394 1055 break;
5395
5396 case left:
5397 case right:
5398
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1459 times.
1460 if(x < 0)
5399 1 x = 0;
5400
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 1027 times.
1459 else if((int32_t(x)&15) > 7)
5401 432 x=(int32_t(x)&0xF0)+16;
5402 else
5403 1027 x=(int32_t(x)&0xF0);
5404
5405 1460 break;
5406 }
5407
5408 2519 sclk=0;
5409 2519 clk3=0;
5410 2519 break;
5411 }
5412 }
5413
5414
2/2
✓ Branch 0 taken 44810 times.
✓ Branch 1 taken 3797 times.
48607 if((sclk&255)==0)
5415 {
5416 //hitdir = -1;
5417 3797 sclk=0;
5418 3797 }
5419 48607 return 2;
5420 9376002 }
5421
5422 bool enemy::can_slide()
5423 {
5424 if(sclk==0 || (hp<=0 && !immortal))
5425 return false;
5426
5427 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5428 {
5429 return false;
5430 }
5431
5432 return true;
5433 }
5434
5435 bool enemy::fslide()
5436 {
5437 if(sclk==0 || (hp<=0 && !immortal))
5438 return false;
5439
5440 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5441 {
5442 sclk=0;
5443 return false;
5444 }
5445
5446 --sclk;
5447
5448 switch(sclk>>8)
5449 {
5450 case up:
5451 if(y<=16)
5452 {
5453 sclk=0;
5454 return false;
5455 }
5456
5457 break;
5458
5459 case down:
5460 if(y>=160)
5461 {
5462 sclk=0;
5463 return false;
5464 }
5465
5466 break;
5467
5468 case left:
5469 if(x<=16)
5470 {
5471 sclk=0;
5472 return false;
5473 }
5474
5475 break;
5476
5477 case right:
5478 if(x>=240)
5479 {
5480 sclk=0;
5481 return false;
5482 }
5483
5484 break;
5485 }
5486 hitdir = (sclk>>8);
5487 switch(sclk>>8)
5488 {
5489 case up:
5490 y-=4;
5491 break;
5492
5493 case down:
5494 y+=4;
5495 break;
5496
5497 case left:
5498 x-=4;
5499 break;
5500
5501 case right:
5502 x+=4;
5503 break;
5504 }
5505
5506 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5507 {
5508 switch(sclk>>8)
5509 {
5510 case up:
5511 case down:
5512 if((int32_t(y)&15) > 7)
5513 y=(int32_t(y)&0xF0)+16;
5514 else
5515 y=(int32_t(y)&0xF0);
5516
5517 break;
5518
5519 case left:
5520 case right:
5521 if((int32_t(x)&15) > 7)
5522 x=(int32_t(x)&0xF0)+16;
5523 else
5524 x=(int32_t(x)&0xF0);
5525
5526 break;
5527 }
5528
5529 sclk=0;
5530 clk3=0;
5531 }
5532
5533 if((sclk&255)==0)
5534 sclk=0;
5535
5536 return true;
5537 }
5538
5539 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5540 {
5541 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5542 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5543 bool ret = sprite::knockback(time, dir, speed);
5544 if(ret) sclk = 0; //kill engine knockback if interrupted
5545 //! Perhaps also set hitdir here, if needed for timing? -Z
5546 return ret;
5547 }
5548
5549 21148620 bool enemy::runKnockback()
5550 {
5551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if((script_knockback_clk&0xFF)==0)
5552 {
5553 21148620 script_knockback_clk = 0;
5554 21148620 return false;
5555 }
5556 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5557 {
5558 return false;
5559 }
5560 int32_t move = script_knockback_speed;
5561 int32_t kb_dir = script_knockback_clk>>8;
5562 --script_knockback_clk;
5563
5564 while(move>0)
5565 {
5566 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5567 move -= thismove;
5568 hitdir = kb_dir;
5569 switch(kb_dir)
5570 {
5571 case r_up:
5572 case l_up:
5573 case up:
5574 y-=thismove;
5575 break;
5576
5577 case r_down:
5578 case l_down:
5579 case down:
5580 y+=thismove;
5581 break;
5582 }
5583 switch(kb_dir)
5584 {
5585 case l_up:
5586 case l_down:
5587 case left:
5588 x-=thismove;
5589 break;
5590
5591 case r_up:
5592 case r_down:
5593 case right:
5594 x+=thismove;
5595 break;
5596 }
5597 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5598 {
5599 if(!canmove(kb_dir,(zfix)0,0,true))
5600 {
5601 script_knockback_clk=0;
5602 clk3=0;
5603 //Fix to grid
5604 switch(kb_dir)
5605 {
5606 case up:
5607 case down:
5608 break;
5609 default:
5610 if(x < 0)
5611 x = 0;
5612 else if((int32_t(x)&15) > 7)
5613 x=(int32_t(x)&0xF0)+16;
5614 else
5615 x=(int32_t(x)&0xF0);
5616 break;
5617 }
5618 switch(kb_dir)
5619 {
5620 case left:
5621 case right:
5622 break;
5623 default:
5624 if(y < 0)
5625 y = 0;
5626 else if((int32_t(y)&15) > 7)
5627 y=(int32_t(y)&0xF0)+16;
5628 else
5629 y=(int32_t(y)&0xF0);
5630 break;
5631 }
5632 break;
5633 }
5634 }
5635 else
5636 {
5637 if(!scr_canplace(x,y,0,true))
5638 {
5639 script_knockback_clk=0;
5640 clk3=0;
5641 //Fix to grid
5642 if (OFFGRID_ENEMY)
5643 {
5644 switch(kb_dir)
5645 {
5646 case up:
5647 case down:
5648 break;
5649 default:
5650 if(x < 0)
5651 x = 0;
5652 else if((int32_t(x)&7) > 3)
5653 x=(int32_t(x)&0xF8)+8;
5654 else
5655 x=(int32_t(x)&0xF8);
5656 break;
5657 }
5658 switch(kb_dir)
5659 {
5660 case left:
5661 case right:
5662 break;
5663 default:
5664 if(y < 0)
5665 y = 0;
5666 else if((int32_t(y)&7) > 3)
5667 y=(int32_t(y)&0xF8)+8;
5668 else
5669 y=(int32_t(y)&0xF8);
5670 break;
5671 }
5672 }
5673 else
5674 {
5675 switch(kb_dir)
5676 {
5677 case up:
5678 case down:
5679 break;
5680 default:
5681 if(x < 0)
5682 x = 0;
5683 else if((int32_t(x)&15) > 7)
5684 x=(int32_t(x)&0xF0)+16;
5685 else
5686 x=(int32_t(x)&0xF0);
5687 break;
5688 }
5689 switch(kb_dir)
5690 {
5691 case left:
5692 case right:
5693 break;
5694 default:
5695 if(y < 0)
5696 y = 0;
5697 else if((int32_t(y)&15) > 7)
5698 y=(int32_t(y)&0xF0)+16;
5699 else
5700 y=(int32_t(y)&0xF0);
5701 break;
5702 }
5703 }
5704 break;
5705 }
5706
5707 }
5708 }
5709 return true;
5710 21148620 }
5711 // changes enemy's direction, checking restrictions
5712 // rate: 0 = no random changes, 16 = always random change
5713 // homing: 0 = none, 256 = always
5714 // grumble 0 = none, 4 = strongest appetite
5715 306188 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5716 {
5717 306188 int32_t ndir=-1;
5718
5719
4/4
✓ Branch 0 taken 73847 times.
✓ Branch 1 taken 232341 times.
✓ Branch 2 taken 26089 times.
✓ Branch 3 taken 47758 times.
306188 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
5720 {
5721 47758 int32_t i = Lwpns.idFirst(wBait);
5722
1/2
✓ Branch 0 taken 47758 times.
✗ Branch 1 not taken.
47758 if(i >= 0) //idfirst returns -1 if it can't find any
5723 {
5724 weapon *w = (weapon*)Lwpns.spr(i);
5725 if (get_qr(qr_FIND_CLOSEST_BAIT))
5726 {
5727 int32_t currentrange;
5728 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5729 else currentrange = -1;
5730 int curid = i;
5731 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5732 for(; i<Lwpns.Count(); ++i)
5733 {
5734 weapon *lw = (weapon*)Lwpns.spr(i);
5735 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5736 {
5737 currentrange = distance(x, y, lw->x, lw->y);
5738 curid = i;
5739 }
5740 }
5741 i = curid;
5742 if (currentrange == -1) i = -1;
5743 }
5744 else
5745 {
5746 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5747 }
5748 if (i >= 0)
5749 {
5750 int32_t bx = Lwpns.spr(i)->x;
5751 int32_t by = Lwpns.spr(i)->y;
5752
5753 if(abs(int32_t(y)-by)>14)
5754 {
5755 ndir = (by<y) ? up : down;
5756 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5757 if(canmove(ndir,special,false))
5758 {
5759 dir=ndir;
5760 return;
5761 }
5762 }
5763
5764 ndir = (bx<x) ? left : right;
5765 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5766 if(canmove(ndir,special,false))
5767 {
5768 dir=ndir;
5769 return;
5770 }
5771 }
5772 }
5773 47758 }
5774
5775
2/2
✓ Branch 0 taken 209238 times.
✓ Branch 1 taken 96950 times.
306188 if((zc_oldrand()&255)<abs(newhoming))
5776 {
5777 96950 ndir = lined_up(8,false);
5778
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96950 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96950 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5779
4/4
✓ Branch 0 taken 25542 times.
✓ Branch 1 taken 71408 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 22186 times.
96950 if(ndir>=0 && canmove(ndir,special,false))
5780 {
5781 22186 dir=ndir;
5782 22186 return;
5783 }
5784 74764 }
5785
5786 284002 int32_t i=0;
5787
5788
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 634621 times.
635878 for(; i<32; i++)
5789 {
5790 634621 int32_t r=zc_oldrand();
5791
5792
2/2
✓ Branch 0 taken 194900 times.
✓ Branch 1 taken 439721 times.
634621 if((r&15)<newrate)
5793 194900 ndir=(r>>4)&3;
5794 else
5795 439721 ndir=dir;
5796
5797
2/2
✓ Branch 0 taken 351876 times.
✓ Branch 1 taken 282745 times.
634621 if(canmove(ndir,special,false))
5798 282745 break;
5799 351876 }
5800
5801
2/2
✓ Branch 0 taken 282745 times.
✓ Branch 1 taken 1257 times.
284431 if(i==32)
5802 {
5803
2/2
✓ Branch 0 taken 3570 times.
✓ Branch 1 taken 429 times.
3999 for(ndir=0; ndir<4; ndir++)
5804 {
5805
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 828 times.
3570 if(canmove(ndir,special,false))
5806 828 goto ok;
5807 2742 }
5808
5809
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 369 times.
429 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5810 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5811 429 }
5812
5813 ok:
5814 284002 dir = ndir;
5815 306188 }
5816
5817 1092 void enemy::newdir()
5818 {
5819 1092 newdir(4,0,spw_none);
5820 1092 }
5821
5822 zfix enemy::distance_left()
5823 {
5824 int32_t a2=x.getInt();
5825 int32_t b2=y.getInt();
5826
5827 switch(dir)
5828 {
5829 case up:
5830 return (zfix)(b2&0xF);
5831
5832 case down:
5833 return (zfix)(16-(b2&0xF));
5834
5835 case left:
5836 return (zfix)(a2&0xF);
5837
5838 case right:
5839 return (zfix)(16-(a2&0xF));
5840 }
5841
5842 return (zfix)0;
5843 }
5844
5845 // keeps walking around
5846 226860 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5847 {
5848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226860 times.
226860 if(slide())
5849 return;
5850
5851
8/12
✓ Branch 0 taken 224557 times.
✓ Branch 1 taken 2303 times.
✓ Branch 2 taken 224557 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 222559 times.
✓ Branch 5 taken 1998 times.
✓ Branch 6 taken 222559 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 222559 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 222559 times.
226860 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5852 4301 return;
5853
5854
2/2
✓ Branch 0 taken 15372 times.
✓ Branch 1 taken 207187 times.
222559 if(clk3<=0)
5855 {
5856 15372 fix_coords(true);
5857 15372 newdir(newrate,newhoming,special);
5858
5859
1/2
✓ Branch 0 taken 15372 times.
✗ Branch 1 not taken.
15372 if(step==0)
5860 clk3=0;
5861 else
5862 15372 clk3=int32_t(16.0/step);
5863 15372 }
5864
2/2
✓ Branch 0 taken 207166 times.
✓ Branch 1 taken 21 times.
207187 else if(scored)
5865 {
5866 21 dir^=1;
5867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5868 else clk3=32767;
5869 21 }
5870
5871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222559 times.
222559 if (step != 0) --clk3;
5872 222559 move(step);
5873 226860 }
5874
5875 void enemy::constant_walk()
5876 {
5877 constant_walk(4,0,spw_none);
5878 }
5879
5880 18230 int32_t enemy::pos(int32_t newx,int32_t newy)
5881 {
5882 18230 return (newy<<8)+newx;
5883 }
5884
5885 // for variable step rates
5886 234267 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5887 {
5888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
234267 if(slide())
5889 return;
5890
5891
10/14
✓ Branch 0 taken 234267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 228560 times.
✓ Branch 5 taken 5707 times.
✓ Branch 6 taken 221271 times.
✓ Branch 7 taken 7289 times.
✓ Branch 8 taken 200047 times.
✓ Branch 9 taken 21224 times.
✓ Branch 10 taken 200047 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 200047 times.
✗ Branch 13 not taken.
234267 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5892 34220 return;
5893
5894 200047 zfix dx = (zfix)0;
5895 200047 zfix dy = (zfix)0;
5896
5897
5/9
✓ Branch 0 taken 43624 times.
✓ Branch 1 taken 44366 times.
✓ Branch 2 taken 53763 times.
✓ Branch 3 taken 56539 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1755 times.
200047 switch(dir)
5898 {
5899 case 8:
5900 case up:
5901 43624 dy-=step;
5902 43624 break;
5903
5904 case 12:
5905 case down:
5906 44366 dy+=step;
5907 44366 break;
5908
5909 case 14:
5910 case left:
5911 53763 dx-=step;
5912 53763 break;
5913
5914 case 10:
5915 case right:
5916 56539 dx+=step;
5917 56539 break;
5918
5919 case 15:
5920 case l_up:
5921 dx-=step;
5922 dy-=step;
5923 break;
5924
5925 case 9:
5926 case r_up:
5927 dx+=step;
5928 dy-=step;
5929 break;
5930
5931 case 13:
5932 case l_down:
5933 dx-=step;
5934 dy+=step;
5935 break;
5936
5937 case 11:
5938 case r_down:
5939 dx+=step;
5940 dy+=step;
5941 break;
5942 }
5943
5944
8/8
✓ Branch 0 taken 95284 times.
✓ Branch 1 taken 104763 times.
✓ Branch 2 taken 12002 times.
✓ Branch 3 taken 83282 times.
✓ Branch 4 taken 5443 times.
✓ Branch 5 taken 6559 times.
✓ Branch 6 taken 193819 times.
✓ Branch 7 taken 6228 times.
200047 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5945 194604 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5946 {
5947 6228 fix_coords();
5948 6228 newdir(newrate,newhoming,special);
5949 6228 clk3=pos(x,y);
5950 6228 }
5951
5952 200047 move(step);
5953 234267 }
5954
5955 // pauses for a while after it makes a complete move (to a new square)
5956 7485806 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5957 {
5958
4/4
✓ Branch 0 taken 41807 times.
✓ Branch 1 taken 7443999 times.
✓ Branch 2 taken 33602 times.
✓ Branch 3 taken 8205 times.
7485806 if(sclk && clk2)
5959 {
5960 8205 clk3=0;
5961 8205 }
5962
5963
11/14
✓ Branch 0 taken 7448916 times.
✓ Branch 1 taken 36890 times.
✓ Branch 2 taken 7448916 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7448916 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7146105 times.
✓ Branch 7 taken 302811 times.
✓ Branch 8 taken 7019314 times.
✓ Branch 9 taken 126791 times.
✓ Branch 10 taken 7017542 times.
✓ Branch 11 taken 1772 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 7017542 times.
7485806 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5964 {
5965 468264 return;
5966 }
5967
5968
2/2
✓ Branch 0 taken 1420795 times.
✓ Branch 1 taken 5596747 times.
7017542 if(clk2>0)
5969 {
5970 1420795 --clk2;
5971 1420795 return;
5972 }
5973
5974
2/2
✓ Branch 0 taken 243580 times.
✓ Branch 1 taken 5353167 times.
5596747 if(clk3<=0)
5975 {
5976 243580 fix_coords(true);
5977 243580 newdir(newrate,newhoming,special);
5978 243580 clk3=int32_t(16.0/step);
5979
2/2
✓ Branch 0 taken 243520 times.
✓ Branch 1 taken 60 times.
243580 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243580 times.
243580 if(clk2<0)
5981 {
5982 clk2=0;
5983 }
5984
2/2
✓ Branch 0 taken 35125 times.
✓ Branch 1 taken 208455 times.
243580 else if((zc_oldrand()&15)<newhrate)
5985 {
5986 35125 clk2=haltcnt;
5987 35125 return;
5988 }
5989 208455 }
5990
2/2
✓ Branch 0 taken 5351685 times.
✓ Branch 1 taken 1482 times.
5353167 else if(scored)
5991 {
5992 1482 dir^=1;
5993
5994
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1481 times.
1482 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5995 1 else clk3=32767;
5996 1482 }
5997
5998
2/2
✓ Branch 0 taken 37087 times.
✓ Branch 1 taken 5524535 times.
5561622 if (step != 0) --clk3;
5999 5561622 move(step);
6000 7485806 }
6001
6002 // 8-directional movement, aligns to 8 pixels
6003 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
6004 {
6005 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6006 return;
6007
6008 if(clk3<=0)
6009 {
6010 newdir_8(newrate,newhoming,special);
6011 clk3=int32_t(8.0/step);
6012 if (step == 0) clk3 = 32767;
6013 }
6014
6015 if (step != 0) --clk3;
6016 move(step);
6017 }
6018 // 8-directional movement, aligns to 8 pixels
6019 84876 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6020 {
6021
6/12
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84876 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84876 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 84876 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 84876 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 84876 times.
84876 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6022 return;
6023
6024
2/2
✓ Branch 0 taken 78734 times.
✓ Branch 1 taken 6142 times.
84876 if(clk3<=0)
6025 {
6026 6142 newdir_8(newrate,newhoming,special);
6027 6142 clk3=int32_t(8.0/step);
6028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6142 times.
6142 if (step == 0) clk3 = 32767;
6029 6142 }
6030
6031
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if (step != 0) --clk3;
6032 84876 move(step);
6033 84876 }
6034
6035 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6036 {
6037 if(clk<0 || dying || stunclk || watch || frozenclock)
6038 return;
6039
6040 if(!canmove(dir,step,special,false))
6041 clk3=0;
6042
6043 if(clk2>0)
6044 {
6045 --clk2;
6046 return;
6047 }
6048
6049 if(clk3<=0)
6050 {
6051 newdir_8(newrate,newhoming,special);
6052 clk3=newclk;
6053
6054 if(clk2<0)
6055 {
6056 clk2=0;
6057 }
6058 else if((zc_oldrand()&15)<newhrate)
6059 {
6060 newdir_8(newrate,newhoming,special);
6061 clk2=haltcnt;
6062 return;
6063 }
6064 }
6065
6066 --clk3;
6067 move(step);
6068 }
6069
6070 // 8-directional movement, no alignment
6071 2513985 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6072 {
6073
9/12
✓ Branch 0 taken 2408462 times.
✓ Branch 1 taken 105523 times.
✓ Branch 2 taken 2408462 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2386969 times.
✓ Branch 5 taken 21493 times.
✓ Branch 6 taken 2377143 times.
✓ Branch 7 taken 9826 times.
✓ Branch 8 taken 2377143 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2377143 times.
2513985 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6074 136842 return;
6075
6076
2/2
✓ Branch 0 taken 2360249 times.
✓ Branch 1 taken 16894 times.
2377143 if(!canmove(dir,step,special,false))
6077 16894 clk3=0;
6078
6079
2/2
✓ Branch 0 taken 2075350 times.
✓ Branch 1 taken 301793 times.
2377143 if(clk3<=0)
6080 {
6081 301793 newdir_8(newrate,newhoming,special);
6082 301793 clk3=newclk;
6083 301793 }
6084
6085 2377143 --clk3;
6086 2377143 move(step);
6087 2513985 }
6088
6089 // same as above but with variable enemy size
6090 52535 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6091 {
6092
8/12
✓ Branch 0 taken 51768 times.
✓ Branch 1 taken 767 times.
✓ Branch 2 taken 51768 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 51768 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 51717 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 51717 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 51717 times.
52535 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6093 818 return;
6094
6095
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 517 times.
51717 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6096 517 clk3=0;
6097
6098
2/2
✓ Branch 0 taken 48239 times.
✓ Branch 1 taken 3478 times.
51717 if(clk3<=0)
6099 {
6100 3478 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6101 3478 clk3=newclk;
6102 3478 }
6103
6104 51717 --clk3;
6105 51717 move(step);
6106 52535 }
6107
6108 // the variable speed floater movement
6109 // ms is max speed
6110 // ss is step speed
6111 // s is step count
6112 // p is pause count
6113 // g is graduality :)
6114 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6115 2107695 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6116 {
6117 2107695 ++clk2;
6118 2107695 byte over_pit = overpit(this);
6119
6120
4/4
✓ Branch 0 taken 424954 times.
✓ Branch 1 taken 1682741 times.
✓ Branch 2 taken 424687 times.
✓ Branch 3 taken 267 times.
2107695 if(dmisc1 && over_pit) p = 0;
6121
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 36911 times.
✓ Branch 2 taken 849849 times.
✓ Branch 3 taken 1135402 times.
✓ Branch 4 taken 85533 times.
2107695 switch(movestatus)
6122 {
6123 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6124 //! if the conditions prevent it, we jump back to case 2.
6125 case 0: // paused
6126
2/2
✓ Branch 0 taken 36222 times.
✓ Branch 1 taken 689 times.
36911 if(clk2>=p)
6127 {
6128 689 movestatus=1;
6129 689 clk2=0;
6130 689 }
6131
6132 36911 break;
6133
6134 case 1: // speeding up
6135
1/2
✓ Branch 0 taken 849849 times.
✗ Branch 1 not taken.
849849 if (s >= 0)
6136 {
6137
2/2
✓ Branch 0 taken 844313 times.
✓ Branch 1 taken 5536 times.
849849 if(clk2<g*s)
6138 {
6139
2/2
✓ Branch 0 taken 790189 times.
✓ Branch 1 taken 54124 times.
844313 if(!((clk2-1)%g))
6140 54124 step+=ss;
6141 844313 }
6142 else
6143 {
6144 5536 movestatus=2;
6145 5536 clk2=0;
6146 }
6147 849849 }
6148 else
6149 {
6150 if(step < ms)
6151 {
6152 if(!((clk2-1)%g))
6153 {
6154 step+=ss;
6155 if (step >= ms) step = ms;
6156 }
6157 }
6158 else
6159 {
6160 step = ms;
6161 movestatus=2;
6162 clk2=0;
6163 }
6164 }
6165
6166 849849 break;
6167
6168 case 2: // normal
6169 1135402 step=ms;
6170
6171
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1135402 times.
✓ Branch 2 taken 237381 times.
✓ Branch 3 taken 898021 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 898021 times.
✓ Branch 6 taken 896841 times.
✓ Branch 7 taken 1180 times.
1135402 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6172 {
6173
1/2
✓ Branch 0 taken 1180 times.
✗ Branch 1 not taken.
1180 if (s >= 0) step=ss*s;
6174 else step=ms;
6175 1180 movestatus=3;
6176 1180 clk2=0;
6177 1180 }
6178
6179 1135402 break;
6180
6181 case 3: // slowing down
6182
1/2
✓ Branch 0 taken 85533 times.
✗ Branch 1 not taken.
85533 if (s >= 0)
6183 {
6184
2/2
✓ Branch 0 taken 84707 times.
✓ Branch 1 taken 826 times.
85533 if(clk2<=g*s)
6185 {
6186 { //don't slow down over pits
6187
6188
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 84695 times.
84707 if(over_pit)
6189 {
6190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(dmisc1)
6191 {
6192 step=ms;
6193 }
6194 12 }
6195 else //can slow down
6196 {
6197
4/4
✓ Branch 0 taken 5242 times.
✓ Branch 1 taken 79453 times.
✓ Branch 2 taken 4970 times.
✓ Branch 3 taken 272 times.
84695 if(!(clk2%g) && !dmisc1)
6198 4970 step-=ss;
6199 }
6200 }
6201
6202
6203 84707 }
6204 else
6205 {
6206 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6207 //this doesn't help keese, as they have a z of 0.
6208 //they always nee to run this check.
6209 {
6210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
826 if(over_pit &&!dmisc1)
6211 {
6212 --clk2; //if over a pit, don't land, and revert clock change
6213 }
6214 else //can land safely
6215 {
6216 826 movestatus=0;
6217
3/4
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 358 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
826 if(dmisc1&&!over_pit)
6218 468 step=0;
6219 826 clk2=0;
6220 }
6221 }
6222
6223 }
6224 85533 }
6225 else
6226 {
6227 if(step > 0)
6228 {
6229 if(over_pit)
6230 {
6231 if(dmisc1)
6232 {
6233 step=ms;
6234 }
6235 }
6236 else //can slow down
6237 {
6238 if(!(clk2%g))
6239 step-=ss;
6240 }
6241 }
6242 else
6243 {
6244 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6245 //this doesn't help keese, as they have a z of 0.
6246 //they always nee to run this check.
6247 if(over_pit)
6248 {
6249 step+=ss; //if over a pit, don't land, and revert clock change
6250 }
6251 else //can land safely
6252 {
6253 movestatus=0;
6254 step=0;
6255 clk2=0;
6256 }
6257 }
6258 }
6259
6260 85533 break;
6261 }
6262
6263
2/2
✓ Branch 0 taken 1139758 times.
✓ Branch 1 taken 967937 times.
2107695 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6264 2107695 }
6265
6266 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6267 {
6268 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6269 }
6270
6271 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6272 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6273 505599 int32_t enemy::lined_up(int32_t range, bool dir8)
6274 {
6275 505599 int32_t lx = Hero.getX();
6276 505599 int32_t ly = Hero.getY();
6277
6278
2/2
✓ Branch 0 taken 19794 times.
✓ Branch 1 taken 485805 times.
505599 if(abs(lx-int32_t(x))<=range)
6279 {
6280
2/2
✓ Branch 0 taken 7913 times.
✓ Branch 1 taken 11881 times.
19794 if(ly<y)
6281 {
6282 7913 return up;
6283 }
6284
6285 11881 return down;
6286 }
6287
6288
2/2
✓ Branch 0 taken 23666 times.
✓ Branch 1 taken 462139 times.
485805 if(abs(ly-int32_t(y))<=range)
6289 {
6290
2/2
✓ Branch 0 taken 12185 times.
✓ Branch 1 taken 11481 times.
23666 if(lx<x)
6291 {
6292 12185 return left;
6293 }
6294
6295 11481 return right;
6296 }
6297
6298
2/2
✓ Branch 0 taken 94764 times.
✓ Branch 1 taken 367375 times.
462139 if(dir8)
6299 {
6300
2/2
✓ Branch 0 taken 130299 times.
✓ Branch 1 taken 237076 times.
367375 if(abs(lx-x)-abs(ly-y)<=range)
6301 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6302 {
6303
2/2
✓ Branch 0 taken 55233 times.
✓ Branch 1 taken 75066 times.
130299 if(ly<y)
6304 {
6305
2/2
✓ Branch 0 taken 32006 times.
✓ Branch 1 taken 23227 times.
55233 if(lx<x)
6306 {
6307 32006 return l_up;
6308 }
6309 else
6310 {
6311 23227 return r_up;
6312 }
6313 }
6314 else
6315 {
6316
2/2
✓ Branch 0 taken 38204 times.
✓ Branch 1 taken 36862 times.
75066 if(lx<x)
6317 {
6318 36862 return l_down;
6319 }
6320 else
6321 {
6322 38204 return r_down;
6323 }
6324 }
6325 }
6326 237076 }
6327
6328 331840 return -1;
6329 505599 }
6330
6331 // returns true if Hero is within 'range' pixels of the enemy
6332 13988 bool enemy::HeroInRange(int32_t range)
6333 {
6334 13988 int32_t lx = Hero.getX();
6335 13988 int32_t ly = Hero.getY();
6336
2/2
✓ Branch 0 taken 11733 times.
✓ Branch 1 taken 2255 times.
13988 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6337 }
6338
6339 // place the enemy in line with Hero (red wizzrobes)
6340 2334 void enemy::place_on_axis(bool floater, bool solid_ok)
6341 {
6342
6/6
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 2129 times.
✓ Branch 3 taken 205 times.
✓ Branch 4 taken 241 times.
✓ Branch 5 taken 1888 times.
2334 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6343
6/6
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 2216 times.
✓ Branch 2 taken 1980 times.
✓ Branch 3 taken 354 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 1862 times.
2334 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6344 2334 int32_t pos2=zc_oldrand()%23;
6345 2334 int32_t tried=0;
6346 2334 bool last_resort,placed=false;
6347
6348
6349 2334 do
6350 {
6351
2/2
✓ Branch 0 taken 2419 times.
✓ Branch 1 taken 1712 times.
4131 if(pos2<14)
6352 {
6353 2419 x=(pos2<<4)+16;
6354 2419 y=ly;
6355 2419 }
6356 else
6357 {
6358 1712 x=lx;
6359 1712 y=((pos2-14)<<4)+16;
6360 }
6361
6362 // Don't commit to a last resort if position is out of bounds.
6363
6/6
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 3808 times.
✓ Branch 3 taken 160 times.
✓ Branch 4 taken 127 times.
✓ Branch 5 taken 3681 times.
4131 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6364
6365
4/4
✓ Branch 0 taken 2148 times.
✓ Branch 1 taken 1983 times.
✓ Branch 2 taken 3739 times.
✓ Branch 3 taken 1591 times.
4131 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6366 {
6367 // Red Wizzrobes should be able to appear on water, but not other
6368 // solid combos; however, they could appear on solid combos in 2.10,
6369 // and some quests depend on that.
6370
4/4
✓ Branch 0 taken 2140 times.
✓ Branch 1 taken 3582 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 2334 times.
5722 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6371 5722 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6372 2334 placed=true;
6373 5722 }
6374
6375
3/6
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 3020 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1797 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4817 if(!placed && tried>=22 && last_resort)
6376 {
6377 placed=true;
6378 }
6379
6380 4817 ++tried;
6381 4817 pos2=(pos2+3)%23;
6382
2/2
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 3020 times.
4817 }
6383 4817 while(!placed);
6384
6385
2/2
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 854 times.
3020 if(y==ly)
6386 2166 dir=(x<lx)?right:left;
6387 else
6388 854 dir=(y<ly)?down:up;
6389
6390 3020 clk2=tried;
6391 3020 }
6392
6393 10524416 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6394 {
6395 10524416 int32_t t = o_tile;
6396 10524416 int32_t b = o_tile;
6397
6398 // Darknuts, but also Wizzrobes and Wallmasters
6399
3/4
✓ Branch 0 taken 3963465 times.
✓ Branch 1 taken 6178051 times.
✓ Branch 2 taken 382900 times.
✗ Branch 3 not taken.
10524416 switch(family)
6400 {
6401 case eeWALK:
6402
5/6
✓ Branch 0 taken 373692 times.
✓ Branch 1 taken 5804359 times.
✓ Branch 2 taken 264807 times.
✓ Branch 3 taken 108885 times.
✓ Branch 4 taken 264807 times.
✗ Branch 5 not taken.
6178051 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6403 {
6404 264807 tile=s_tile;
6405 264807 t=s_tile;
6406 264807 b=s_tile;
6407 264807 }
6408
6409 6178051 break;
6410
6411 case eeTRAP:
6412
4/6
✓ Branch 0 taken 141238 times.
✓ Branch 1 taken 241662 times.
✓ Branch 2 taken 141238 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 141238 times.
382900 if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure
6413 {
6414 141238 tile=s_tile;
6415 141238 t=s_tile;
6416 141238 b=s_tile;
6417 141238 }
6418
6419 382900 break;
6420
6421 case eeSPINTILE:
6422 if(misc>=96 && do_animation)
6423 {
6424 tile=o_tile+frames*ndir;
6425 t=tile;
6426 }
6427
6428 break;
6429 }
6430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10524416 times.
10524416 if ( do_animation )
6431 {
6432
4/6
✓ Branch 0 taken 163042 times.
✓ Branch 1 taken 10361374 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266817 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10094557 times.
10524416 if(ndir!=0) switch(frames)
6433 {
6434 case 2:
6435 266817 tiledir_small(dir,ndir==4);
6436 266817 break;
6437
6438 case 3:
6439 tiledir_three(dir);
6440 break;
6441
6442 case 4:
6443 10094557 tiledir(dir,ndir==4);
6444 10094557 break;
6445 10361374 }
6446
6447
2/2
✓ Branch 0 taken 6178051 times.
✓ Branch 1 taken 4346365 times.
10524416 if(family==eeWALK)
6448
6/6
✓ Branch 0 taken 6167527 times.
✓ Branch 1 taken 10524 times.
✓ Branch 2 taken 4638452 times.
✓ Branch 3 taken 1539599 times.
✓ Branch 4 taken 1537069 times.
✓ Branch 5 taken 2530 times.
6178051 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6449 else
6450 4346365 tile+=f4;
6451 10524416 }
6452 10524416 return b;
6453 }
6454
6455 void enemy::tiledir_three(int32_t ndir)
6456 {
6457 if ( !do_animation ) return;
6458 flip=0;
6459
6460 switch(ndir)
6461 {
6462 case right:
6463 tile+=3;
6464 [[fallthrough]];
6465
6466 case left:
6467 tile+=3;
6468 [[fallthrough]];
6469
6470 case down:
6471 tile+=3;
6472 [[fallthrough]];
6473
6474 case up:
6475 break;
6476 }
6477 }
6478
6479 266817 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6480 {
6481
1/2
✓ Branch 0 taken 266817 times.
✗ Branch 1 not taken.
266817 if ( !do_animation ) return;
6482 266817 flip=0;
6483
6484
8/9
✓ Branch 0 taken 53728 times.
✓ Branch 1 taken 54633 times.
✓ Branch 2 taken 67625 times.
✓ Branch 3 taken 71117 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
266817 switch(ndir)
6485 {
6486 case 8:
6487 case up:
6488 53728 break;
6489
6490 case 12:
6491 case down:
6492 54633 tile+=2;
6493 54633 break;
6494
6495 case 14:
6496 case left:
6497 67625 tile+=4;
6498 67625 break;
6499
6500 case 10:
6501 case right:
6502 71117 tile+=6;
6503 71117 break;
6504
6505 case 9:
6506 case r_up:
6507
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6508 5706 break;
6509
6510 tile+=10;
6511 break;
6512
6513 case 11:
6514 case r_down:
6515
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6516 5154 tile+=2;
6517 else
6518 tile+=14;
6519
6520 5154 break;
6521
6522 case 13:
6523 case l_down:
6524
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6525 4872 tile+=2;
6526 else
6527 tile+=12;
6528
6529 4872 break;
6530
6531 case 15:
6532 case l_up:
6533
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6534 3982 break;
6535
6536 tile+=8;
6537 break;
6538
6539 default:
6540 //dir=(zc_oldrand()*100)%8;
6541 //tiledir_small(dir);
6542 // flip=zc_oldrand()&3;
6543 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6544 break;
6545 }
6546 266817 }
6547
6548 11660468 void enemy::tiledir(int32_t ndir, bool fourdir)
6549 {
6550
1/2
✓ Branch 0 taken 11660468 times.
✗ Branch 1 not taken.
11660468 if ( !do_animation ) return;
6551 11660468 flip=0;
6552
6553
9/9
✓ Branch 0 taken 2359939 times.
✓ Branch 1 taken 2044242 times.
✓ Branch 2 taken 2781916 times.
✓ Branch 3 taken 2670926 times.
✓ Branch 4 taken 406885 times.
✓ Branch 5 taken 486841 times.
✓ Branch 6 taken 474500 times.
✓ Branch 7 taken 419015 times.
✓ Branch 8 taken 16204 times.
11660468 switch(ndir)
6554 {
6555 case 8:
6556 case up:
6557 2359939 break;
6558
6559 case 12:
6560 case down:
6561 2044242 tile+=4;
6562 2044242 break;
6563
6564 case 14:
6565 case left:
6566 2781916 tile+=8;
6567 2781916 break;
6568
6569 case 10:
6570 case right:
6571 2670926 tile+=12;
6572 2670926 break;
6573
6574 case 9:
6575 case r_up:
6576
2/2
✓ Branch 0 taken 57693 times.
✓ Branch 1 taken 349192 times.
406885 if(fourdir)
6577 57693 break;
6578 else
6579 349192 tile+=24;
6580
6581 349192 break;
6582
6583 case 11:
6584 case r_down:
6585
2/2
✓ Branch 0 taken 63504 times.
✓ Branch 1 taken 423337 times.
486841 if(fourdir)
6586 63504 tile+=4;
6587 else
6588 423337 tile+=32;
6589
6590 486841 break;
6591
6592 case 13:
6593 case l_down:
6594
2/2
✓ Branch 0 taken 66073 times.
✓ Branch 1 taken 408427 times.
474500 if(fourdir)
6595 66073 tile+=4;
6596 else
6597 408427 tile+=28;
6598
6599 474500 break;
6600
6601 case 15:
6602 case l_up:
6603
2/2
✓ Branch 0 taken 50160 times.
✓ Branch 1 taken 368855 times.
419015 if(fourdir)
6604 50160 break;
6605 else
6606 368855 tile+=20;
6607
6608 368855 break;
6609
6610 default:
6611 //dir=(zc_oldrand()*100)%8;
6612 //tiledir(dir);
6613 // flip=zc_oldrand()&3;
6614 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6615 16204 break;
6616 }
6617 11660468 }
6618
6619 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6620 {
6621
1/2
✓ Branch 0 taken 3868 times.
✗ Branch 1 not taken.
3868 if ( !do_animation ) return;
6622 3868 flip=0;
6623
6624
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6625 {
6626 case 8:
6627 case up:
6628 297 break;
6629
6630 case 12:
6631 case down:
6632 tile+=8;
6633 break;
6634
6635 case 14:
6636 case left:
6637 195 tile+=40;
6638 195 break;
6639
6640 case 10:
6641 case right:
6642 179 tile+=48;
6643 179 break;
6644
6645 case 9:
6646 case r_up:
6647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6648 break;
6649
6650 306 tile+=88;
6651 306 break;
6652
6653 case 11:
6654 case r_down:
6655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6656 tile+=8;
6657 else
6658 1235 tile+=128;
6659
6660 1235 break;
6661
6662 case 13:
6663 case l_down:
6664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6665 tile+=8;
6666 else
6667 1324 tile+=120;
6668
6669 1324 break;
6670
6671 case 15:
6672 case l_up:
6673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6674 break;
6675
6676 332 tile+=80;
6677 332 break;
6678
6679 default:
6680 //dir=(zc_oldrand()*100)%8;
6681 //tiledir_big(dir);
6682 // flip=zc_oldrand()&3;
6683 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6684 break;
6685 }
6686 3868 }
6687
6688 22905054 void enemy::update_enemy_frame()
6689 {
6690
3/4
✓ Branch 0 taken 22904912 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22904912 times.
22905054 if(fallclk||drownclk) return;
6691
1/2
✓ Branch 0 taken 22904912 times.
✗ Branch 1 not taken.
22904912 if (!do_animation)
6692 return;
6693
6694
3/4
✓ Branch 0 taken 153758 times.
✓ Branch 1 taken 22751154 times.
✓ Branch 2 taken 153758 times.
✗ Branch 3 not taken.
22904912 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6695
6696
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
22904912 if(get_qr(qr_ANONE_NOANIM)
6697
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22904912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22904912 && anim == aNONE && family != eeGUY)
6698 return;
6699
2/2
✓ Branch 0 taken 45769 times.
✓ Branch 1 taken 22859143 times.
22904912 int32_t newfrate = zc_max(frate,4);
6700 22904912 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6701 22904912 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6702
2/2
✓ Branch 0 taken 15606509 times.
✓ Branch 1 taken 7298403 times.
22904912 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6703 22904912 tile = o_tile;
6704 22904912 int32_t basetile = o_tile;
6705 22904912 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6706 22904912 bool ignore_extend = false;
6707
34/40
✓ Branch 0 taken 164903 times.
✓ Branch 1 taken 5459 times.
✓ Branch 2 taken 38520 times.
✓ Branch 3 taken 1313148 times.
✓ Branch 4 taken 216057 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89141 times.
✓ Branch 7 taken 233641 times.
✓ Branch 8 taken 128056 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2773771 times.
✓ Branch 12 taken 41139 times.
✓ Branch 13 taken 50626 times.
✓ Branch 14 taken 818 times.
✓ Branch 15 taken 353574 times.
✓ Branch 16 taken 622431 times.
✓ Branch 17 taken 163042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 98223 times.
✓ Branch 20 taken 157529 times.
✓ Branch 21 taken 428287 times.
✓ Branch 22 taken 1050207 times.
✓ Branch 23 taken 934304 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 266817 times.
✓ Branch 26 taken 2408805 times.
✓ Branch 27 taken 3857795 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 399313 times.
✓ Branch 30 taken 912736 times.
✓ Branch 31 taken 614651 times.
✓ Branch 32 taken 161932 times.
✓ Branch 33 taken 1317852 times.
✓ Branch 34 taken 74670 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 3483844 times.
✓ Branch 37 taken 281552 times.
✓ Branch 38 taken 219227 times.
✓ Branch 39 taken 38974 times.
22904912 switch(anim)
6708 {
6709
6710 case aDONGO:
6711 {
6712 41139 int32_t fr = stunclk>0 ? 16 : 8;
6713
6714
6/6
✓ Branch 0 taken 39717 times.
✓ Branch 1 taken 1422 times.
✓ Branch 2 taken 4800 times.
✓ Branch 3 taken 34917 times.
✓ Branch 4 taken 1600 times.
✓ Branch 5 taken 3200 times.
41139 if(!dying && clk2>0 && clk2<=64)
6715 {
6716 // bloated
6717
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 448 times.
✓ Branch 3 taken 1152 times.
✓ Branch 4 taken 768 times.
3200 switch(dir)
6718 {
6719 case up:
6720 832 tile+=9;
6721 832 flip=0;
6722 832 xofs=0;
6723 832 dummy_int[1]=0; //no additional tiles
6724 832 break;
6725
6726 case down:
6727 448 tile+=7;
6728 448 flip=0;
6729 448 xofs=0;
6730 448 dummy_int[1]=0; //no additional tiles
6731 448 break;
6732
6733 case left:
6734 1152 flip=1;
6735 1152 tile+=4;
6736 1152 xofs=16;
6737 1152 dummy_int[1]=1; //second tile is next tile
6738 1152 break;
6739
6740 case right:
6741 768 flip=0;
6742 768 tile+=5;
6743 768 xofs=16;
6744 768 dummy_int[1]=-1; //second tile is previous tile
6745 768 break;
6746 }
6747 3200 }
6748
4/4
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 36517 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 783 times.
37939 else if(!dying || clk2>19)
6749 {
6750 // normal
6751
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7974 times.
✓ Branch 2 taken 8400 times.
✓ Branch 3 taken 12214 times.
✓ Branch 4 taken 8568 times.
37156 switch(dir)
6752 {
6753 case up:
6754 7974 tile+=8;
6755 7974 flip=(clk&fr)?1:0;
6756 7974 xofs=0;
6757 7974 dummy_int[1]=0; //no additional tiles
6758 7974 break;
6759
6760 case down:
6761 8400 tile+=6;
6762 8400 flip=(clk&fr)?1:0;
6763 8400 xofs=0;
6764 8400 dummy_int[1]=0; //no additional tiles
6765 8400 break;
6766
6767 case left:
6768 12214 flip=1;
6769 12214 tile+=(clk&fr)?2:0;
6770 12214 xofs=16;
6771 12214 dummy_int[1]=1; //second tile is next tile
6772 12214 break;
6773
6774 case right:
6775 8568 flip=0;
6776 8568 tile+=(clk&fr)?3:1;
6777 8568 xofs=16;
6778 8568 dummy_int[1]=-1; //second tile is next tile
6779 8568 break;
6780 }
6781 37156 }
6782 }
6783 41139 break;
6784
6785 case aNEWDONGO:
6786 {
6787 50626 int32_t fr4=0;
6788
6789
6/6
✓ Branch 0 taken 48878 times.
✓ Branch 1 taken 1748 times.
✓ Branch 2 taken 3936 times.
✓ Branch 3 taken 44942 times.
✓ Branch 4 taken 1312 times.
✓ Branch 5 taken 2624 times.
50626 if(!dying && clk2>0 && clk2<=64)
6790 {
6791 // bloated
6792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2624 times.
2624 if(clk2>=0)
6793 {
6794 2624 fr4=3;
6795 2624 }
6796
6797
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 2009 times.
2624 if(clk2>=16)
6798 {
6799 2009 fr4=2;
6800 2009 }
6801
6802
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 1353 times.
2624 if(clk2>=32)
6803 {
6804 1353 fr4=1;
6805 1353 }
6806
6807
2/2
✓ Branch 0 taken 1927 times.
✓ Branch 1 taken 697 times.
2624 if(clk2>=48)
6808 {
6809 697 fr4=0;
6810 697 }
6811
6812
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1088 times.
2624 switch(dir)
6813 {
6814 case up:
6815 256 xofs=0;
6816 256 tile+=8+fr4;
6817 256 dummy_int[1]=0; //no additional tiles
6818 256 break;
6819
6820 case down:
6821 576 xofs=0;
6822 576 tile+=12+fr4;
6823 576 dummy_int[1]=0; //no additional tiles
6824 576 break;
6825
6826 case left:
6827 704 tile+=29+(2*fr4);
6828 704 xofs=16;
6829 704 dummy_int[1]=-1; //second tile is previous tile
6830 704 break;
6831
6832 case right:
6833 1088 tile+=49+(2*fr4);
6834 1088 xofs=16;
6835 1088 dummy_int[1]=-1; //second tile is previous tile
6836 1088 break;
6837 }
6838 2624 }
6839
4/4
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 46254 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 825 times.
48002 else if(!dying || clk2>19)
6840 {
6841 // normal
6842
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9019 times.
✓ Branch 2 taken 9429 times.
✓ Branch 3 taken 14024 times.
✓ Branch 4 taken 14705 times.
47177 switch(dir)
6843 {
6844 case up:
6845 9019 xofs=0;
6846 9019 tile+=((clk&12)>>2);
6847 9019 dummy_int[1]=0; //no additional tiles
6848 9019 break;
6849
6850 case down:
6851 9429 xofs=0;
6852 9429 tile+=4+((clk&12)>>2);
6853 9429 dummy_int[1]=0; //no additional tiles
6854 9429 break;
6855
6856 case left:
6857 14024 tile+=21+((clk&12)>>1);
6858 14024 xofs=16;
6859 14024 dummy_int[1]=-1; //second tile is previous tile
6860 14024 break;
6861
6862 case right:
6863 14705 flip=0;
6864 14705 tile+=41+((clk&12)>>1);
6865 14705 xofs=16;
6866 14705 dummy_int[1]=-1; //second tile is previous tile
6867 14705 break;
6868 }
6869 47177 }
6870 }
6871 50626 break;
6872
6873 case aDONGOBS:
6874 {
6875 818 int32_t fr4=0;
6876
6877
6/6
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 590 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 128 times.
818 if(!dying && clk2>0 && clk2<=64)
6878 {
6879 // bloated
6880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(clk2>=0)
6881 {
6882 128 fr4=3;
6883 128 }
6884
6885
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(clk2>=16)
6886 {
6887 98 fr4=2;
6888 98 }
6889
6890
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 66 times.
128 if(clk2>=32)
6891 {
6892 66 fr4=1;
6893 66 }
6894
6895
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 34 times.
128 if(clk2>=48)
6896 {
6897 34 fr4=0;
6898 34 }
6899
6900
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
128 switch(dir)
6901 {
6902 case up:
6903 tile+=28+fr4;
6904 yofs+=8;
6905 dummy_int[1]=-20; //second tile change
6906 dummy_int[2]=0; //new xofs change
6907 dummy_int[3]=-16; //new xofs change
6908 break;
6909
6910 case down:
6911 tile+=12+fr4;
6912 yofs-=8;
6913 dummy_int[1]=20; //second tile change
6914 dummy_int[2]=0; //new xofs change
6915 dummy_int[3]=16; //new xofs change
6916 break;
6917
6918 case left:
6919 128 tile+=49+(2*fr4);
6920 128 xofs+=8;
6921 128 dummy_int[1]=-1; //second tile change
6922 128 dummy_int[2]=-16; //new xofs change
6923 128 dummy_int[3]=0; //new xofs change
6924 128 break;
6925
6926 case right:
6927 tile+=69+(2*fr4);
6928 xofs+=8;
6929 dummy_int[1]=-1; //second tile change
6930 dummy_int[2]=-16; //new xofs change
6931 dummy_int[3]=0; //new xofs change
6932 break;
6933 }
6934 128 }
6935
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
690 else if(!dying || clk2>19)
6936 {
6937 // normal
6938
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 97 times.
654 switch(dir)
6939 {
6940 case up:
6941 96 tile+=20+((clk&24)>>3);
6942 96 yofs+=8;
6943 96 dummy_int[1]=-20; //second tile change
6944 96 dummy_int[2]=0; //new xofs change
6945 96 dummy_int[3]=-16; //new xofs change
6946 96 break;
6947
6948 case down:
6949 129 tile+=4+((clk&24)>>3);
6950 129 yofs-=8;
6951 129 dummy_int[1]=20; //second tile change
6952 129 dummy_int[2]=0; //new xofs change
6953 129 dummy_int[3]=16; //new xofs change
6954 129 break;
6955
6956 case left:
6957 332 xofs=-8;
6958 332 tile+=40+((clk&24)>>2);
6959 332 dummy_int[1]=1; //second tile change
6960 332 dummy_int[2]=16; //new xofs change
6961 332 dummy_int[3]=0; //new xofs change
6962 332 break;
6963
6964 case right:
6965 97 tile+=60+((clk&24)>>2);
6966 97 xofs=-8;
6967 97 dummy_int[1]=1; //second tile change
6968 97 dummy_int[2]=16; //new xofs change
6969 97 dummy_int[3]=0; //new xofs change
6970 97 break;
6971 }
6972 654 }
6973 }
6974 818 break;
6975
6976 case aWIZZ:
6977 {
6978 // if(d->misc1)
6979
2/2
✓ Branch 0 taken 139048 times.
✓ Branch 1 taken 214526 times.
353574 if(dmisc1)
6980 {
6981
2/2
✓ Branch 0 taken 69275 times.
✓ Branch 1 taken 69773 times.
139048 if(clk&8)
6982 {
6983 69773 ++tile;
6984 69773 }
6985 139048 }
6986 else
6987 {
6988
2/2
✓ Branch 0 taken 107350 times.
✓ Branch 1 taken 107176 times.
214526 if(frame&4)
6989 {
6990 107176 ++tile;
6991 107176 }
6992 }
6993
6994
4/4
✓ Branch 0 taken 55328 times.
✓ Branch 1 taken 124116 times.
✓ Branch 2 taken 114795 times.
✓ Branch 3 taken 59335 times.
353574 switch(dir)
6995 {
6996 case 9:
6997 case 15:
6998 case up:
6999 55328 tile+=2;
7000 55328 break;
7001
7002 case down:
7003 59335 break;
7004
7005 case 13:
7006 case left:
7007 124116 flip=1;
7008 124116 break;
7009
7010 default:
7011 114795 flip=0;
7012 114795 break;
7013 }
7014 }
7015 353574 break;
7016
7017 case aNEWWIZZ:
7018 {
7019 622431 tiledir(dir,true);
7020
7021 // if(d->misc1) //walking wizzrobe
7022
2/2
✓ Branch 0 taken 330881 times.
✓ Branch 1 taken 291550 times.
622431 if(dmisc1) //walking wizzrobe
7023 {
7024
2/2
✓ Branch 0 taken 166270 times.
✓ Branch 1 taken 164611 times.
330881 if(clk&8)
7025 {
7026 164611 tile+=2;
7027 164611 }
7028
7029
2/2
✓ Branch 0 taken 165827 times.
✓ Branch 1 taken 165054 times.
330881 if(clk&4)
7030 {
7031 165054 tile+=1;
7032 165054 }
7033
7034
2/4
✓ Branch 0 taken 330881 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 330881 times.
330881 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7035 {
7036
2/2
✓ Branch 0 taken 296297 times.
✓ Branch 1 taken 34584 times.
330881 if(dummy_int[1]>0)
7037 {
7038 34584 tile+=40;
7039 34584 }
7040 330881 }
7041 330881 }
7042 else
7043 {
7044
4/4
✓ Branch 0 taken 267218 times.
✓ Branch 1 taken 24332 times.
✓ Branch 2 taken 62854 times.
✓ Branch 3 taken 204364 times.
291550 if(dummy_bool[1]||dummy_bool[2])
7045 {
7046 87186 tile+=20;
7047
7048
2/2
✓ Branch 0 taken 24332 times.
✓ Branch 1 taken 62854 times.
87186 if(dummy_bool[2])
7049 {
7050 62854 tile+=20;
7051 62854 }
7052 87186 }
7053
7054 291550 tile+=((frame>>1)&3);
7055 }
7056 }
7057 622431 break;
7058
7059 case a3FRM:
7060 {
7061
2/2
✓ Branch 0 taken 38762 times.
✓ Branch 1 taken 124280 times.
163042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7062 }
7063 163042 break;
7064
7065 case a3FRM4DIR:
7066 {
7067 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7068 }
7069 break;
7070
7071 case aVIRE:
7072 {
7073
2/2
✓ Branch 0 taken 76001 times.
✓ Branch 1 taken 22222 times.
98223 if(dir==up)
7074 {
7075 22222 tile+=2;
7076 22222 }
7077
7078 98223 tile+=fx;
7079 }
7080 98223 break;
7081
7082 case aROPE:
7083 {
7084 164903 tile+=(1-fx);
7085 164903 flip = dir==left ? 1:0;
7086 }
7087 164903 break;
7088
7089 case aZORA:
7090 {
7091 int32_t dl;
7092
7093
2/2
✓ Branch 0 taken 33018 times.
✓ Branch 1 taken 124511 times.
157529 if(clk<36)
7094 {
7095 33018 dl=clk+5;
7096 33018 goto waves2;
7097 }
7098
7099
2/2
✓ Branch 0 taken 58613 times.
✓ Branch 1 taken 65898 times.
124511 if(clk<36+66)
7100
2/2
✓ Branch 0 taken 33479 times.
✓ Branch 1 taken 25134 times.
58613 tile=(dir==up)?o_tile+1:o_tile;
7101 else
7102 {
7103 65898 dl=clk-36-66;
7104 waves2:
7105 98916 tile=((dl/11)&1)+s_tile;
7106 98916 basetile = s_tile;
7107 }
7108 }
7109 157529 break;
7110
7111 case aNEWZORA:
7112 {
7113 428287 f4=(clk/16)%4;
7114
7115 428287 tiledir(dir,true);
7116 int32_t dl;
7117
7118
4/4
✓ Branch 0 taken 304957 times.
✓ Branch 1 taken 123330 times.
✓ Branch 2 taken 159809 times.
✓ Branch 3 taken 145148 times.
428287 if((clk>35)&&(clk<36+67)) //surfaced
7119 {
7120
4/4
✓ Branch 0 taken 123977 times.
✓ Branch 1 taken 21171 times.
✓ Branch 2 taken 17680 times.
✓ Branch 3 taken 106297 times.
145148 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7121 {
7122 106297 tile+=80;
7123 106297 } //mouth closed
7124 else
7125 {
7126 38851 tile+=40;
7127 }
7128
7129 145148 tile+=f4;
7130 145148 }
7131 else
7132 {
7133
2/2
✓ Branch 0 taken 123330 times.
✓ Branch 1 taken 159809 times.
283139 if(clk<36)
7134 {
7135 123330 dl=clk+5;
7136 123330 }
7137 else
7138 {
7139 159809 dl=clk-36-66;
7140 }
7141
7142 283139 tile+=((dl/5)&3);
7143 }
7144 }
7145 428287 break;
7146
7147 case a4FRM4EYE:
7148 case a2FRM4EYE:
7149 case a4FRM8EYE:
7150 case a4FRM8EYEB: //big version
7151 case a4FRM4EYEB:
7152 {
7153 128056 tilerows = 2;
7154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128056 times.
128056 int fakex = x + 8*(zc_max(1,txsz)-1);
7155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128056 times.
128056 int fakey = y + 8*(zc_max(1,tysz)-1);
7156 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7157 128056 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7158 128056 int32_t lookat=zc_oldrand()&15;
7159
7160
4/4
✓ Branch 0 taken 40954 times.
✓ Branch 1 taken 87102 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20770 times.
128056 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7161 {
7162 20770 lookat=l_down;
7163 20770 }
7164
4/4
✓ Branch 0 taken 41196 times.
✓ Branch 1 taken 66090 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 21012 times.
107286 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7165 {
7166 21012 lookat=down;
7167 21012 }
7168
4/4
✓ Branch 0 taken 33446 times.
✓ Branch 1 taken 52828 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 13262 times.
86274 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7169 {
7170 13262 lookat=r_down;
7171 13262 }
7172
4/4
✓ Branch 0 taken 32038 times.
✓ Branch 1 taken 40974 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 11854 times.
73012 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7173 {
7174 11854 lookat=right;
7175 11854 }
7176
4/4
✓ Branch 0 taken 25060 times.
✓ Branch 1 taken 36098 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 4876 times.
61158 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7177 {
7178 4876 lookat=r_up;
7179 4876 }
7180
4/4
✓ Branch 0 taken 26018 times.
✓ Branch 1 taken 30264 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 5834 times.
56282 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7181 {
7182 5834 lookat=up;
7183 5834 }
7184
4/4
✓ Branch 0 taken 30200 times.
✓ Branch 1 taken 20248 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 10016 times.
50448 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7185 {
7186 10016 lookat=l_up;
7187 10016 }
7188 else
7189 {
7190 40432 lookat=left;
7191 }
7192
7193 128056 int32_t dir2 = dir;
7194 128056 dir = lookat;
7195
3/6
✓ Branch 0 taken 128056 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128056 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128056 times.
128056 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7196 else
7197 {
7198 tiledir_big(dir,(anim == a4FRM4EYEB));
7199 tile+=2*f4;
7200 ignore_extend = true;
7201 }
7202 128056 dir = dir2;
7203 }
7204 128056 break;
7205
7206 case aFLIP:
7207 {
7208 1050207 flip = f2&1;
7209 }
7210 1050207 break;
7211
7212 case a2FRM:
7213 {
7214 934304 tile += (1-f2);
7215 }
7216 934304 break;
7217
7218 case a2FRMB:
7219 {
7220 tile+= 2*(1-f2);
7221 ignore_extend = true;
7222 }
7223 break;
7224
7225 case a2FRM4DIR:
7226 {
7227 266817 basetile = n_frame_n_dir(2, 4, f2&1);
7228 }
7229 266817 break;
7230
7231 case a4FRM4DIRF:
7232 {
7233 2408805 basetile = n_frame_n_dir(4,4,f4);
7234
7235
2/2
✓ Branch 0 taken 1574669 times.
✓ Branch 1 taken 834136 times.
2408805 if(clk2>0) //stopped to fire
7236 {
7237 834136 tile+=20;
7238
7239
2/2
✓ Branch 0 taken 413682 times.
✓ Branch 1 taken 420454 times.
834136 if(clk2<17) //firing
7240 {
7241 420454 tile+=20;
7242 420454 }
7243 834136 }
7244 }
7245 2408805 break;
7246
7247 case a4FRM4DIR:
7248 {
7249 3857795 basetile = n_frame_n_dir(4,4,f4);
7250 }
7251 3857795 break;
7252
7253 case a4FRM8DIRF:
7254 {
7255 tilerows = 2;
7256 basetile = n_frame_n_dir(4,8,f4);
7257
7258 if(clk2>0) //stopped to fire
7259 {
7260 tile+=40;
7261
7262 if(clk2<17) //firing
7263 {
7264 tile+=40;
7265 }
7266 }
7267 }
7268 break;
7269
7270 case a4FRM8DIRB:
7271 case a4FRM8DIRFB:
7272 {
7273 3868 tilerows = 2;
7274 3868 tiledir_big(dir,false);
7275 3868 tile+=2*f4;
7276
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7277 {
7278 tile+=80;
7279
7280 if(clk2<17) //firing
7281 {
7282 tile+=80;
7283 }
7284 }
7285 3868 ignore_extend = true;
7286 }
7287 3868 break;
7288
7289 case a4FRM4DIRB:
7290 case a4FRM4DIRFB:
7291 {
7292 tilerows = 2;
7293 tiledir_big(dir,true);
7294 tile+=2*f4;
7295 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7296 {
7297 tile+=40;
7298
7299 if(clk2<17) //firing
7300 {
7301 tile+=40;
7302 }
7303 }
7304 ignore_extend = true;
7305 }
7306 break;
7307
7308 case aOCTO:
7309 {
7310
5/5
✓ Branch 0 taken 2913 times.
✓ Branch 1 taken 85458 times.
✓ Branch 2 taken 96229 times.
✓ Branch 3 taken 112826 times.
✓ Branch 4 taken 101887 times.
399313 switch(dir)
7311 {
7312 case up:
7313 85458 flip = 2;
7314 85458 break;
7315
7316 case down:
7317 96229 flip = 0;
7318 96229 break;
7319
7320 case left:
7321 112826 flip = 0;
7322 112826 tile += 2;
7323 112826 break;
7324
7325 case right:
7326 101887 flip = 1;
7327 101887 tile += 2;
7328 101887 break;
7329 }
7330
7331 399313 tile+=f2;
7332 }
7333 399313 break;
7334
7335 case aWALK:
7336 {
7337
5/5
✓ Branch 0 taken 4582 times.
✓ Branch 1 taken 187339 times.
✓ Branch 2 taken 207694 times.
✓ Branch 3 taken 256906 times.
✓ Branch 4 taken 256215 times.
912736 switch(dir)
7338 {
7339 case up:
7340 187339 tile+=3;
7341 187339 flip = f2;
7342 187339 break;
7343
7344 case down:
7345 207694 tile+=2;
7346 207694 flip = f2;
7347 207694 break;
7348
7349 case left:
7350 256906 flip=1;
7351 256906 tile += f2;
7352 256906 break;
7353
7354 case right:
7355 256215 flip=0;
7356 256215 tile += f2;
7357 256215 break;
7358 }
7359 }
7360 912736 break;
7361
7362 case aDWALK:
7363 {
7364
3/4
✓ Branch 0 taken 81208 times.
✓ Branch 1 taken 533443 times.
✓ Branch 2 taken 81208 times.
✗ Branch 3 not taken.
614651 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7365 {
7366 tile=s_tile;
7367 basetile = s_tile;
7368 }
7369
7370
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 129268 times.
✓ Branch 2 taken 133261 times.
✓ Branch 3 taken 177242 times.
✓ Branch 4 taken 174880 times.
614651 switch(dir)
7371 {
7372 case up:
7373 129268 tile+=2;
7374 129268 flip=f2;
7375 129268 break;
7376
7377 case down:
7378 133261 flip=0;
7379 133261 tile+=(1-f2);
7380 133261 break;
7381
7382 case left:
7383 177242 flip=1;
7384 177242 tile+=(3+f2);
7385 177242 break;
7386
7387 case right:
7388 174880 flip=0;
7389 174880 tile+=(3+f2);
7390 174880 break;
7391 }
7392 }
7393 614651 break;
7394
7395 case aTEK:
7396 {
7397
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 60556 times.
161932 if(misc==0)
7398 {
7399 60556 tile += f2;
7400 60556 }
7401
2/2
✓ Branch 0 taken 53958 times.
✓ Branch 1 taken 47418 times.
101376 else if(misc!=1)
7402 {
7403 47418 ++tile;
7404 47418 }
7405 }
7406 161932 break;
7407
7408 case aNEWTEK:
7409 {
7410
2/2
✓ Branch 0 taken 329922 times.
✓ Branch 1 taken 987930 times.
1317852 if(step<0) //up
7411 {
7412
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 162358 times.
✓ Branch 2 taken 167564 times.
329922 switch(clk3)
7413 {
7414 case left:
7415 162358 flip=0;
7416 162358 tile+=20;
7417 162358 break;
7418
7419 case right:
7420 167564 flip=0;
7421 167564 tile+=24;
7422 167564 break;
7423 }
7424 329922 }
7425
2/2
✓ Branch 0 taken 42115 times.
✓ Branch 1 taken 945815 times.
987930 else if(step==0)
7426 {
7427
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31831 times.
✓ Branch 2 taken 10284 times.
42115 switch(clk3)
7428 {
7429 case left:
7430 31831 flip=0;
7431 31831 tile+=8;
7432 31831 break;
7433
7434 case right:
7435 10284 flip=0;
7436 10284 tile+=12;
7437 10284 break;
7438 }
7439 42115 } //down
7440 else
7441 {
7442
3/3
✓ Branch 0 taken 64726 times.
✓ Branch 1 taken 445156 times.
✓ Branch 2 taken 435933 times.
945815 switch(clk3)
7443 {
7444 case left:
7445 445156 flip=0;
7446 445156 tile+=28;
7447 445156 break;
7448
7449 case right:
7450 435933 flip=0;
7451 435933 tile+=32;
7452 435933 break;
7453 }
7454 }
7455
7456
2/2
✓ Branch 0 taken 845637 times.
✓ Branch 1 taken 472215 times.
1317852 if(misc==0)
7457 {
7458 472215 tile+=f4;
7459 472215 }
7460
2/2
✓ Branch 0 taken 408849 times.
✓ Branch 1 taken 436788 times.
845637 else if(misc!=1)
7461 {
7462 436788 tile+=2;
7463 436788 }
7464 }
7465 1317852 break;
7466
7467 case aARMOS:
7468 {
7469
2/2
✓ Branch 0 taken 2153 times.
✓ Branch 1 taken 3306 times.
5459 if(!fading)
7470 {
7471 3306 tile += fx;
7472
7473
2/2
✓ Branch 0 taken 2459 times.
✓ Branch 1 taken 847 times.
3306 if(dir==up)
7474 847 tile += 2;
7475 3306 }
7476 }
7477 5459 break;
7478
7479 case aARMOS4:
7480 {
7481
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6349 times.
✓ Branch 2 taken 13276 times.
✓ Branch 3 taken 9550 times.
✓ Branch 4 taken 9345 times.
38520 switch(dir)
7482 {
7483 case up:
7484 6349 flip=0;
7485 6349 break;
7486
7487 case down:
7488 13276 flip=0;
7489 13276 tile+=4;
7490 13276 break;
7491
7492 case left:
7493 9550 flip=0;
7494 9550 tile+=8;
7495 9550 break;
7496
7497 case right:
7498 9345 flip=0;
7499 9345 tile+=12;
7500 9345 break;
7501 }
7502
7503
2/2
✓ Branch 0 taken 7161 times.
✓ Branch 1 taken 31359 times.
38520 if(!fading)
7504 {
7505 31359 tile+=f4;
7506 31359 }
7507 }
7508 38520 break;
7509
7510 case aGHINI:
7511 {
7512
4/4
✓ Branch 0 taken 14931 times.
✓ Branch 1 taken 18961 times.
✓ Branch 2 taken 40404 times.
✓ Branch 3 taken 374 times.
74670 switch(dir)
7513 {
7514 case 8:
7515 case 9:
7516 case up:
7517 14931 ++tile;
7518 14931 flip=0;
7519 14931 break;
7520
7521 case 15:
7522 374 ++tile;
7523 374 flip=1;
7524 374 break;
7525
7526 case 10:
7527 case 11:
7528 case right:
7529 18961 flip=1;
7530 18961 break;
7531
7532 default:
7533 40404 flip=0;
7534 40404 break;
7535 }
7536 }
7537 74670 break;
7538
7539 case a2FRMPOS:
7540 {
7541 1313148 tile+=posframe;
7542 }
7543 1313148 break;
7544
7545 case a4FRMPOS4DIR:
7546 {
7547 216057 basetile = n_frame_n_dir(4,4,0);
7548 // tile+=f2;
7549 216057 tile+=posframe;
7550 }
7551 216057 break;
7552
7553 case a4FRMPOS4DIRF:
7554 {
7555 basetile = n_frame_n_dir(4,4,0);
7556
7557 if(clk2>0) //stopped to fire
7558 {
7559 tile+=20;
7560
7561 if(clk2<17) //firing
7562 {
7563 tile+=20;
7564 }
7565 }
7566
7567 // tile+=f2;
7568 tile+=posframe;
7569 }
7570 break;
7571
7572 case a4FRMPOS8DIR:
7573 {
7574 3483844 tilerows = 2;
7575 3483844 int32_t n = tile;
7576 3483844 basetile = n_frame_n_dir(4,8,0);
7577 // tile+=f2;
7578 3483844 tile+=posframe;
7579 }
7580 3483844 break;
7581
7582 case a4FRMPOS8DIRF:
7583 {
7584 tilerows = 2;
7585 basetile = n_frame_n_dir(4,8,0);
7586
7587 if(clk2>0) //stopped to fire
7588 {
7589 tile+=40;
7590
7591 if(clk2<17) //firing
7592 {
7593 tile+=40;
7594 }
7595 }
7596
7597 tile+=posframe;
7598 }
7599 break;
7600
7601 case aNEWLEV:
7602 {
7603 281552 tiledir(dir,true);
7604
7605
4/5
✓ Branch 0 taken 92775 times.
✓ Branch 1 taken 45501 times.
✓ Branch 2 taken 18315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124961 times.
281552 switch(misc)
7606 {
7607 case -1:
7608 case 0:
7609 92775 return;
7610
7611 case 1:
7612
7613 // case 5: cs = d->misc2; break;
7614 case 5:
7615 45501 cs = dmisc2;
7616 45501 break;
7617
7618 case 2:
7619 case 4:
7620 18315 tile += 20;
7621 18315 break;
7622
7623 case 3:
7624 124961 tile += 40;
7625 124961 break;
7626 }
7627
7628 188777 tile+=f4;
7629 }
7630 188777 break;
7631
7632 case aLEV:
7633 {
7634 219227 f4 = ((clk/5)&1);
7635
7636
4/5
✓ Branch 0 taken 106859 times.
✓ Branch 1 taken 24845 times.
✓ Branch 2 taken 11238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76285 times.
219227 switch(misc)
7637 {
7638 case -1:
7639 case 0:
7640 106859 return;
7641
7642 case 1:
7643
7644 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7645 case 5:
7646 24845 tile += (f2) ? 1 : 0;
7647 24845 cs = dmisc2;
7648 24845 break;
7649
7650 case 2:
7651 case 4:
7652 11238 tile += 2;
7653 11238 break;
7654
7655 case 3:
7656 76285 tile += (f4) ? 4 : 3;
7657 76285 break;
7658 }
7659 }
7660 112368 break;
7661
7662 case aWALLM:
7663 {
7664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89141 times.
89141 if(!dummy_bool[1])
7665 {
7666 89141 tile += f2;
7667 89141 }
7668 }
7669 89141 break;
7670
7671 case aNEWWALLM:
7672 {
7673 233641 int32_t tempdir=0;
7674
7675
4/4
✓ Branch 0 taken 30389 times.
✓ Branch 1 taken 24290 times.
✓ Branch 2 taken 6721 times.
✓ Branch 3 taken 172241 times.
233641 switch(misc)
7676 {
7677 case 1:
7678 case 2:
7679 24290 tempdir=clk3;
7680 24290 break;
7681
7682 case 3:
7683 case 4:
7684 case 5:
7685 30389 tempdir=dir;
7686 30389 break;
7687
7688 case 6:
7689 case 7:
7690 6721 tempdir=clk3^1;
7691 6721 break;
7692 }
7693
7694 233641 tiledir(tempdir,true);
7695
7696
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 233063 times.
233641 if(!dummy_bool[1])
7697 {
7698 233063 tile+=f4;
7699 233063 }
7700 }
7701 233641 break;
7702
7703 case a4FRMNODIR:
7704 {
7705 38974 tile+=f4;
7706 }
7707 38974 break;
7708
7709 } // switch(d->anim)
7710
7711 // flashing
7712 // if(d->flags2 & guy_flashing)
7713
2/2
✓ Branch 0 taken 22180744 times.
✓ Branch 1 taken 524534 times.
22705278 if(flags2 & guy_flashing)
7714 {
7715 524534 cs = (frame&3) + 6;
7716 524534 }
7717
7718
2/2
✓ Branch 0 taken 22673164 times.
✓ Branch 1 taken 32114 times.
22705278 if(flags2&guy_transparent)
7719 {
7720 32114 drawstyle=1;
7721 32114 }
7722
7723 22705278 int32_t change = tile-basetile;
7724
7725
3/6
✓ Branch 0 taken 1174288 times.
✓ Branch 1 taken 21530990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1174288 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22705278 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7726 {
7727
2/2
✓ Branch 0 taken 953842 times.
✓ Branch 1 taken 220446 times.
1174288 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7728 {
7729 953842 tile=basetile+txsz*change;
7730 953842 }
7731 else
7732 {
7733 220446 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7734 }
7735 1174288 }
7736 else
7737 {
7738 21530990 tile=basetile+change;
7739 }
7740 22905054 }
7741
7742 53882 int32_t wpnsfx(int32_t wpn)
7743 {
7744
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17500 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 18023 times.
✓ Branch 4 taken 11644 times.
✓ Branch 5 taken 6432 times.
53882 switch(wpn)
7745 {
7746 case ewFireTrail:
7747 case ewFlame:
7748 case ewFlame2Trail:
7749 case ewFlame2:
7750 17500 return WAV_FIRE;
7751
7752 case ewWind:
7753 case ewMagic:
7754 283 return WAV_WAND;
7755
7756 case ewIce:
7757 return WAV_ZN1ICE;
7758
7759 case ewRock:
7760
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 6168 times.
6432 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1ROCK;
7761 6168 break;
7762
7763 case ewFireball2:
7764 case ewFireball:
7765
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 18016 times.
18023 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
7766 18016 }
7767
7768 35828 return -1;
7769 53882 }
7770
7771 42799961 int32_t enemy::run_script(int32_t mode)
7772 {
7773
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42799961 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42799961 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7774
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42799961 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42799961 if (script <= 0 || !doscript || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7775 42799961 return RUNSCRIPT_OK;
7776 int32_t ret = RUNSCRIPT_OK;
7777 alloc_scriptmem();
7778 switch(mode)
7779 {
7780 case MODE_NORMAL:
7781 return ZScriptVersion::RunScript(ScriptType::NPC, script, getUID());
7782 case MODE_WAITDRAW:
7783 if(waitdraw)
7784 {
7785 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, getUID());
7786 waitdraw = 0;
7787 }
7788 break;
7789 }
7790 return ret;
7791 42799961 }
7792 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7793 {
7794 return al_map_rgba(255,0,0,opacity);
7795 }
7796 /********************************/
7797 /********* Guy Class **********/
7798 /********************************/
7799
7800 // good guys, fires, fairy, and other non-enemies
7801 // based on enemy class b/c guys in dungeons act sort of like enemies
7802 // also easier to manage all the guys this way
7803 1440 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7804 1440 {
7805 1440 mainguy=mg;
7806 1440 canfreeze=false;
7807 1440 dir=down;
7808
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1440 times.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
1440 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7809 1440 hxofs=2;
7810 1440 hzsz=8;
7811 1440 hit_width=12;
7812 1440 hit_height=17;
7813
7814
10/12
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✓ Branch 5 taken 980 times.
✓ Branch 6 taken 450 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 205 times.
✓ Branch 9 taken 245 times.
✓ Branch 10 taken 14 times.
✓ Branch 11 taken 191 times.
1440 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
7815 {
7816 1249 superman = 1;
7817 1249 hxofs=1000;
7818 1249 }
7819 1440 }
7820
7821 563152 bool guy::animate(int32_t index)
7822 {
7823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 563152 times.
563152 if(switch_hooked) return enemy::animate(index);
7824
6/6
✓ Branch 0 taken 271227 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 2123 times.
✓ Branch 3 taken 269104 times.
✓ Branch 4 taken 1406 times.
✓ Branch 5 taken 717 times.
563152 if(mainguy && clk==0 && misc==0)
7825 {
7826 717 setupscreen();
7827 717 misc = 1;
7828 717 }
7829
7830
4/4
✓ Branch 0 taken 271227 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 271014 times.
✓ Branch 3 taken 213 times.
563152 if(mainguy && fadeclk==0)
7831 213 return true;
7832
7833 562939 hp=256; // good guys never die...
7834
7835
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 562644 times.
✓ Branch 2 taken 286 times.
✓ Branch 3 taken 9 times.
562939 if(hclk && !clk2)
7836 {
7837 // but if they get hit...
7838 9 ++clk2; // only do this once
7839
7840
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 if(!get_qr(qr_NOGUYFIRES))
7841 {
7842 1 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
7843 1 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
7844 1 }
7845 9 }
7846
7847 562939 return enemy::animate(index);
7848 563152 }
7849
7850 566391 void guy::draw(BITMAP *dest)
7851 {
7852 566391 update_enemy_frame();
7853
7854
6/6
✓ Branch 0 taken 274338 times.
✓ Branch 1 taken 292053 times.
✓ Branch 2 taken 14309 times.
✓ Branch 3 taken 260029 times.
✓ Branch 4 taken 7153 times.
✓ Branch 5 taken 7156 times.
566391 if(!mainguy || fadeclk<0 || fadeclk&1)
7855 559235 enemy::draw(dest);
7856 566391 }
7857
7858 /*******************************/
7859 /********* Enemies *********/
7860 /*******************************/
7861
7862 374 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7863 374 {
7864 374 clk4=0;
7865 374 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7866 // Spawn type
7867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if(flags & guy_fadeflicker)
7868 {
7869 clk=0;
7870 superman = 1;
7871 fading=fade_flicker;
7872 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7873 dir=down;
7874
7875 if(!canmove(down,(zfix)8,spw_none,false))
7876 clk3=int32_t(13.0/step);
7877 }
7878
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 else if(flags & guy_fadeinstant)
7879 {
7880 clk=0;
7881 }
7882 374 SIZEflags = d->SIZEflags;
7883
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
7884 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
7885 // al_trace("Enemy txsz:%i\n", txsz);
7886
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
7887
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
7888
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
7889
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
7890
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
7891
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
7892 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
7893
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
7894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
7895 {
7896 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
7897 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
7898 }
7899
7900
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs;
7901 374 }
7902
7903 78853 bool eFire::animate(int32_t index)
7904 {
7905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78853 times.
78853 if(switch_hooked) return enemy::animate(index);
7906
2/4
✓ Branch 0 taken 78853 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78853 times.
78853 if(fallclk||drownclk) return enemy::animate(index);
7907
2/2
✓ Branch 0 taken 78278 times.
✓ Branch 1 taken 575 times.
78853 if(fading)
7908 {
7909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 if(++clk4 > 60)
7910 {
7911 clk4=0;
7912 superman=0;
7913 fading=0;
7914
7915 if(flags2&cmbflag_armos && z==0 && fakez==0)
7916 removearmos(x,y,ffcactivated);
7917
7918 clk2=0;
7919
7920 if(!canmove(down,(zfix)8,spw_none,false))
7921 {
7922 dir=0;
7923 y = y.getInt() & 0xF0;
7924 }
7925
7926 return Dead(index);
7927 }
7928
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
575 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
7929 removearmos(x,y,ffcactivated);
7930 575 }
7931
7932 78853 return enemy::animate(index);
7933 78853 }
7934
7935 166722 void eFire::draw(BITMAP *dest)
7936 {
7937 166722 update_enemy_frame();
7938 166722 enemy::draw(dest);
7939 166722 }
7940
7941 149 int32_t eFire::takehit(weapon *w, weapon* realweap)
7942 {
7943 149 int32_t wpnId = w->id;
7944 149 int32_t wpnDir = w->dir;
7945
7946
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7947 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
7948 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
7949 {
7950 shield = false;
7951 flags &= ~(inv_left|inv_right|inv_back|inv_front);
7952
7953 if(get_qr(qr_BRKNSHLDTILES))
7954 o_tile=s_tile;
7955 }
7956
7957 149 int32_t ret = enemy::takehit(w,realweap);
7958 149 return ret;
7959 }
7960
7961 void eFire::break_shield()
7962 {
7963 if(!shield)
7964 return;
7965
7966 flags&=~(inv_front | inv_back | inv_left | inv_right);
7967 shield=false;
7968
7969 if(get_qr(qr_BRKNSHLDTILES))
7970 o_tile=s_tile;
7971 }
7972
7973 4900 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7974 4900 {
7975 //zprint2("npct other::other\n");
7976 4900 clk4=0;
7977 4900 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7978
7979 // Spawn type
7980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
4900 if(flags & guy_fadeflicker)
7981 {
7982 clk=0;
7983 superman = 1;
7984 fading=fade_flicker;
7985 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7986 dir=down;
7987
7988 if(!canmove(down,(zfix)8,spw_none,false))
7989 clk3=int32_t(13.0/step);
7990 }
7991
2/2
✓ Branch 0 taken 4729 times.
✓ Branch 1 taken 171 times.
4900 else if(flags & guy_fadeinstant)
7992 {
7993 171 clk=0;
7994 171 }
7995 4900 SIZEflags = d->SIZEflags;
7996
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
7997 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
7998 // al_trace("Enemy txsz:%i\n", txsz);
7999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8000
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8001
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8003
1/2
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8004
1/2
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8005 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8006
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8008 {
8009 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8010 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8011 }
8012
8013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8014 4900 }
8015
8016 917976 bool eOther::animate(int32_t index)
8017 {
8018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 917976 times.
917976 if(switch_hooked) return enemy::animate(index);
8019
2/4
✓ Branch 0 taken 917976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 917976 times.
917976 if(fallclk||drownclk) return enemy::animate(index);
8020 //zprint2("npct other::animate\n");
8021
2/2
✓ Branch 0 taken 916640 times.
✓ Branch 1 taken 1336 times.
917976 if(fading)
8022 {
8023
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1335 times.
1336 if(++clk4 > 60)
8024 {
8025 1 clk4=0;
8026 1 superman=0;
8027 1 fading=0;
8028
8029
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags2&cmbflag_armos && z==0 && fakez==0)
8030 removearmos(x,y,ffcactivated);
8031
8032 1 clk2=0;
8033
8034
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!canmove(down,(zfix)8,spw_none,false))
8035 {
8036 dir=0;
8037 y = y.getInt() & 0xF0;
8038 }
8039
8040 1 return Dead(index);
8041 }
8042
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1335 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1335 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8043 removearmos(x,y,ffcactivated);
8044 1335 }
8045
8046 917975 return enemy::animate(index);
8047 917976 }
8048
8049 944738 void eOther::draw(BITMAP *dest)
8050 {
8051 944738 update_enemy_frame();
8052 944738 enemy::draw(dest);
8053 944738 }
8054
8055 5691 int32_t eOther::takehit(weapon *w, weapon* realweap)
8056 {
8057 5691 int32_t wpnId = w->id;
8058 5691 int32_t wpnDir = w->dir;
8059
8060
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 5674 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
5691 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8061 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8062 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8063 {
8064 shield = false;
8065 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8066
8067 if(get_qr(qr_BRKNSHLDTILES))
8068 o_tile=s_tile;
8069 }
8070
8071 5691 int32_t ret = enemy::takehit(w,realweap);
8072 5691 return ret;
8073 }
8074
8075 void eOther::break_shield()
8076 {
8077 if(!shield)
8078 return;
8079
8080 flags&=~(inv_front | inv_back | inv_left | inv_right);
8081 shield=false;
8082
8083 if(get_qr(qr_BRKNSHLDTILES))
8084 o_tile=s_tile;
8085 }
8086
8087
8088 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8089 {
8090 clk4=0;
8091 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8092
8093 // Spawn type
8094 if(flags & guy_fadeflicker)
8095 {
8096 clk=0;
8097 superman = 1;
8098 fading=fade_flicker;
8099 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8100 dir=down;
8101
8102 if(!canmove(down,(zfix)8,spw_none,false))
8103 clk3=int32_t(13.0/step);
8104 }
8105 else if(flags & guy_fadeinstant)
8106 {
8107 clk=0;
8108 }
8109 SIZEflags = d->SIZEflags;
8110 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8111 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8112 // al_trace("Enemy txsz:%i\n", txsz);
8113 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8114 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8115 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8116 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8117 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8118 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8119 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8120 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8121 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8122 {
8123 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8124 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8125 }
8126
8127 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8128 }
8129
8130 bool eScript::animate(int32_t index)
8131 {
8132 if(switch_hooked) return enemy::animate(index);
8133 if(fallclk||drownclk) return enemy::animate(index);
8134 if(fading)
8135 {
8136 if(++clk4 > 60)
8137 {
8138 clk4=0;
8139 superman=0;
8140 fading=0;
8141
8142 if(flags2&cmbflag_armos && z==0 && fakez==0)
8143 removearmos(x,y,ffcactivated);
8144
8145 clk2=0;
8146
8147 if(!canmove(down,(zfix)8,spw_none,false))
8148 {
8149 dir=0;
8150 y = y.getInt() & 0xF0;
8151 }
8152
8153 return Dead(index);
8154 }
8155 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8156 removearmos(x,y,ffcactivated);
8157 }
8158
8159 return enemy::animate(index);
8160 }
8161
8162 void eScript::draw(BITMAP *dest)
8163 {
8164 update_enemy_frame();
8165 enemy::draw(dest);
8166 }
8167
8168 int32_t eScript::takehit(weapon *w, weapon* realweap)
8169 {
8170 int32_t wpnId = w->id;
8171 int32_t wpnDir = w->dir;
8172
8173 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8174 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8175 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8176 {
8177 shield = false;
8178 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8179
8180 if(get_qr(qr_BRKNSHLDTILES))
8181 o_tile=s_tile;
8182 }
8183
8184 int32_t ret = enemy::takehit(w,realweap);
8185 return ret;
8186 }
8187
8188 void eScript::break_shield()
8189 {
8190 if(!shield)
8191 return;
8192
8193 flags&=~(inv_front | inv_back | inv_left | inv_right);
8194 shield=false;
8195
8196 if(get_qr(qr_BRKNSHLDTILES))
8197 o_tile=s_tile;
8198 }
8199
8200
8201 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8202 {
8203 clk4=0;
8204 hyofs = -32768; //No hitbox initially.
8205 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8206
8207 // Spawn type
8208 if(flags & guy_fadeflicker)
8209 {
8210 clk=0;
8211 superman = 1;
8212 fading=fade_flicker;
8213 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8214 dir=down;
8215
8216 if(!canmove(down,(zfix)8,spw_none,false))
8217 clk3=int32_t(13.0/step);
8218 }
8219 else if(flags & guy_fadeinstant)
8220 {
8221 clk=0;
8222 }
8223 SIZEflags = d->SIZEflags;
8224 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8225 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8226 // al_trace("Enemy txsz:%i\n", txsz);
8227 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8228 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8229 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8230 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8231 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8232 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8233 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8234 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8235 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8236 {
8237 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8238 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8239 }
8240
8241 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8242 }
8243
8244 bool eFriendly::animate(int32_t index)
8245 {
8246 if(switch_hooked) return enemy::animate(index);
8247 if(fallclk||drownclk) return enemy::animate(index);
8248 if(fading)
8249 {
8250 if(++clk4 > 60)
8251 {
8252 clk4=0;
8253 superman=0;
8254 fading=0;
8255
8256 if(flags2&cmbflag_armos && z==0 && fakez==0)
8257 removearmos(x,y,ffcactivated);
8258
8259 clk2=0;
8260
8261 if(!canmove(down,(zfix)8,spw_none,false))
8262 {
8263 dir=0;
8264 y = y.getInt() & 0xF0;
8265 }
8266
8267 return Dead(index);
8268 }
8269 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8270 removearmos(x,y,ffcactivated);
8271 }
8272
8273 return enemy::animate(index);
8274 }
8275
8276 void eFriendly::draw(BITMAP *dest)
8277 {
8278 update_enemy_frame();
8279 enemy::draw(dest);
8280 }
8281
8282 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8283 {
8284 int32_t wpnId = w->id;
8285 int32_t wpnDir = w->dir;
8286
8287 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8288 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8289 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8290 {
8291 shield = false;
8292 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8293
8294 if(get_qr(qr_BRKNSHLDTILES))
8295 o_tile=s_tile;
8296 }
8297
8298 int32_t ret = enemy::takehit(w,realweap);
8299 return ret;
8300 }
8301
8302 void eFriendly::break_shield()
8303 {
8304 if(!shield)
8305 return;
8306
8307 flags&=~(inv_front | inv_back | inv_left | inv_right);
8308 shield=false;
8309
8310 if(get_qr(qr_BRKNSHLDTILES))
8311 o_tile=s_tile;
8312 }
8313
8314
8315 354130 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
8316 {
8317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354130 times.
354130 if (ffcactive)
8318 {
8319 removearmosffc(ffcactive-1);
8320 return;
8321 }
8322
2/2
✓ Branch 0 taken 353464 times.
✓ Branch 1 taken 666 times.
354130 if(did_armos)
8323 {
8324 353464 return;
8325 }
8326
8327 666 did_armos=true;
8328 666 ax&=0xF0;
8329 666 ay&=0xF0;
8330 666 int32_t cd = (ax>>4)+ay;
8331 666 int32_t f = MAPFLAG(ax,ay);
8332 666 int32_t f2 = MAPCOMBOFLAG(ax,ay);
8333
8334
2/2
✓ Branch 0 taken 545 times.
✓ Branch 1 taken 121 times.
666 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
8335 {
8336 545 return;
8337 }
8338
8339 121 tmpscr->data[cd] = tmpscr->undercombo;
8340 121 tmpscr->cset[cd] = tmpscr->undercset;
8341 121 tmpscr->sflag[cd] = 0;
8342
8343
3/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101 times.
121 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8344 {
8345 20 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
8346 20 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
8347 20 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
8348 20 sfx(tmpscr->secretsfx);
8349 20 }
8350
8351
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
121 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8352 {
8353
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8354 {
8355 2 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8356 2 sfx(tmpscr->secretsfx);
8357 2 }
8358 2 }
8359
8360 121 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
8361 354130 }
8362
8363 void enemy::removearmosffc(int32_t pos)
8364 {
8365 if(did_armos)
8366 {
8367 return;
8368 }
8369
8370 did_armos=true;
8371 ffcdata& ffc = tmpscr->ffcs[pos];
8372 newcombo const& cmb = combobuf[ffc.data];
8373 int32_t f2 = cmb.flag;
8374
8375 if(cmb.type!=cARMOS)
8376 {
8377 return;
8378 }
8379
8380 zc_ffc_set(ffc, tmpscr->undercombo);
8381 ffc.cset = tmpscr->undercset;
8382
8383 if(f2 == mfARMOS_SECRET)
8384 {
8385 zc_ffc_set(ffc, tmpscr->secretcombo[sSTAIRS]);
8386 ffc.cset = tmpscr->secretcset[sSTAIRS];
8387 sfx(tmpscr->secretsfx);
8388 }
8389
8390 if(f2 == mfARMOS_ITEM)
8391 {
8392 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8393 {
8394 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8395 sfx(tmpscr->secretsfx);
8396 }
8397 }
8398
8399 putcombo(scrollbuf,ffc.x,ffc.y,ffc.data,ffc.cset);
8400 }
8401
8402
8403 140 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8404 140 {
8405 140 fading=fade_flicker;
8406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8407 140 dir=12;
8408 140 movestatus=1;
8409
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 step=0;
8410 140 clk=0;
8411 140 clk4=0;
8412 140 SIZEflags = d->SIZEflags;
8413
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8414 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8415 // al_trace("Enemy txsz:%i\n", txsz);
8416
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8417
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8418
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8419
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8420
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8421
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8422 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8423
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8425 {
8426 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8427 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8428 }
8429
8430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8431 140 }
8432
8433 51269 bool eGhini::animate(int32_t index)
8434 {
8435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51269 times.
51269 if(switch_hooked) return enemy::animate(index);
8436
2/4
✓ Branch 0 taken 51269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51269 times.
51269 if(fallclk||drownclk) return enemy::animate(index);
8437
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 51233 times.
51269 if(dying)
8438 36 return Dead(index);
8439
8440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51233 times.
51233 if(dmisc1)
8441 {
8442
2/2
✓ Branch 0 taken 42826 times.
✓ Branch 1 taken 8407 times.
51233 if(misc)
8443 {
8444
2/2
✓ Branch 0 taken 11785 times.
✓ Branch 1 taken 31041 times.
42826 if(clk4>160)
8445 31041 misc=2;
8446
8447
2/2
✓ Branch 0 taken 11785 times.
✓ Branch 1 taken 31041 times.
42826 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8448 42826 removearmos(x,y,ffcactivated);
8449 42826 }
8450
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 135 times.
8407 else if(clk4>=60)
8451 {
8452 135 misc=1;
8453 135 clk3=32;
8454 135 fading=0;
8455
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if (ffcactivated > 0)
8456 {
8457 guygridffc[ffcactivated-1] = 0;
8458 removearmosffc(ffcactivated-1);
8459 }
8460 else
8461 {
8462 135 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
8463 135 removearmos(x,y);
8464 }
8465 135 }
8466 51233 }
8467
8468 51233 clk4++;
8469
8470 51233 return enemy::animate(index);
8471 51269 }
8472
8473 102598 void eGhini::draw(BITMAP *dest)
8474 {
8475 102598 update_enemy_frame();
8476 102598 enemy::draw(dest);
8477 102598 }
8478
8479 2 void eGhini::kickbucket()
8480 {
8481 2 hp=-1000; // don't call death_sfx()
8482 2 }
8483
8484
2/4
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2941 times.
✗ Branch 3 not taken.
5882 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8485 2941 {
8486
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 old_y=y;
8487 2941 dir=down;
8488 2941 misc=1;
8489 2941 clk=-15;
8490
8491
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 573 times.
2941 if(!BSZ)
8492
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 clk*=zc_oldrand()%3+1;
8493
8494 // avoid divide by 0 errors
8495
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if(dmisc1 == 0)
8496 dmisc1 = 24;
8497
8498
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if(dmisc2 == 0)
8499 dmisc2 = 3;
8500
8501 //nets+760;
8502 2941 SIZEflags = d->SIZEflags;
8503
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8504 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8505 // al_trace("Enemy txsz:%i\n", txsz);
8506
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8507
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8508
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8509
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8510
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8511
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8512 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8515 {
8516 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8517 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8518 }
8519
8520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8521 2941 }
8522
8523 910945 bool eTektite::animate(int32_t index)
8524 {
8525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 910945 times.
910945 if(switch_hooked) return enemy::animate(index);
8526
4/4
✓ Branch 0 taken 903407 times.
✓ Branch 1 taken 7538 times.
✓ Branch 2 taken 7538 times.
✓ Branch 3 taken 909605 times.
910945 if(fallclk||drownclk) return enemy::animate(index);
8527
2/2
✓ Branch 0 taken 19019 times.
✓ Branch 1 taken 890586 times.
909605 if(dying)
8528 19019 return Dead(index);
8529
8530
2/2
✓ Branch 0 taken 867887 times.
✓ Branch 1 taken 22699 times.
890586 if(clk==0)
8531 {
8532 22699 removearmos(x,y,ffcactivated);
8533 22699 }
8534
8535
2/2
✓ Branch 0 taken 557452 times.
✓ Branch 1 taken 333134 times.
890586 if(get_qr(qr_ENEMIESZAXIS))
8536 {
8537 333134 y=floor_y;
8538 333134 }
8539
8540
9/10
✓ Branch 0 taken 805094 times.
✓ Branch 1 taken 85492 times.
✓ Branch 2 taken 798089 times.
✓ Branch 3 taken 7005 times.
✓ Branch 4 taken 798089 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 786913 times.
✓ Branch 8 taken 3360 times.
✓ Branch 9 taken 11586 times.
890586 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8541 {
8542
4/4
✓ Branch 0 taken 9968 times.
✓ Branch 1 taken 310803 times.
✓ Branch 2 taken 206484 times.
✓ Branch 3 taken 271244 times.
798499 switch(misc)
8543 {
8544 case 0: // normal
8545
2/2
✓ Branch 0 taken 304080 times.
✓ Branch 1 taken 6723 times.
310803 if(!(zc_oldrand()%dmisc1))
8546 {
8547 6723 misc=1;
8548 6723 clk2=32;
8549 6723 }
8550
8551 310803 break;
8552
8553 case 1: // waiting to pounce
8554
2/2
✓ Branch 0 taken 195359 times.
✓ Branch 1 taken 11125 times.
206484 if(--clk2<=0)
8555 {
8556 11125 int32_t r=zc_oldrand();
8557 11125 misc=2;
8558 11125 step=0-(zslongToFix(dstep*100)); // initial speed
8559 11125 clk3=(r&1)+2; // left or right
8560 11125 clk2start=clk2=(r&31)+10; // flight time
8561
8562
2/2
✓ Branch 0 taken 9762 times.
✓ Branch 1 taken 1363 times.
11125 if(y<32) clk2+=2; // make them come down from top of screen
8563
8564
2/2
✓ Branch 0 taken 8659 times.
✓ Branch 1 taken 2466 times.
11125 if(y>112) clk2-=2; // make them go back up
8565
8566 11125 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8567 11125 }
8568
8569 206484 break;
8570
8571 case 2: // in flight
8572 271244 move(step);
8573
8574
2/2
✓ Branch 0 taken 130352 times.
✓ Branch 1 taken 140892 times.
271244 if(step>0) //going down
8575 {
8576
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 130196 times.
130352 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8577 {
8578 156 step=0-step;
8579 156 }
8580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8581 {
8582 step=0-step;
8583 }
8584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(ispitfall(x+8,y+16))
8585 {
8586 step=0-step;
8587 }
8588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8589 {
8590 step=0-step;
8591 }
8592
1/2
✓ Branch 0 taken 130196 times.
✗ Branch 1 not taken.
130196 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8593 {
8594 step=0-step;
8595 }
8596 130352 }
8597
2/2
✓ Branch 0 taken 9095 times.
✓ Branch 1 taken 131797 times.
140892 else if(step<0)
8598 {
8599
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 131578 times.
131797 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8600 {
8601 219 step=0-step;
8602 219 }
8603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8604 {
8605 step=0-step;
8606 }
8607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(ispitfall(x+8,y))
8608 {
8609 step=0-step;
8610 }
8611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8612 {
8613 step=0-step;
8614 }
8615
1/2
✓ Branch 0 taken 131578 times.
✗ Branch 1 not taken.
131578 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8616 {
8617 step=0-step;
8618 }
8619 131797 }
8620
8621
2/2
✓ Branch 0 taken 134483 times.
✓ Branch 1 taken 136761 times.
271244 if(clk3==left)
8622 {
8623
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 134382 times.
134483 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8624 {
8625 101 clk3^=1;
8626 101 }
8627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8628 {
8629 clk3^=1;
8630 }
8631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(ispitfall(x,y+8))
8632 {
8633 clk3^=1;
8634 }
8635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8636 {
8637 clk3^=1;
8638 }
8639
1/2
✓ Branch 0 taken 134382 times.
✗ Branch 1 not taken.
134382 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8640 {
8641 clk3^=1;
8642 }
8643 134483 }
8644 else
8645 {
8646
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 136670 times.
136761 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8647 {
8648 91 clk3^=1;
8649 91 }
8650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8651 {
8652 clk3^=1;
8653 }
8654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(ispitfall(x+16,y+8))
8655 {
8656 clk3^=1;
8657 }
8658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8659 {
8660 clk3^=1;
8661 }
8662
1/2
✓ Branch 0 taken 136670 times.
✗ Branch 1 not taken.
136670 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8663 {
8664 clk3^=1;
8665 }
8666 }
8667
8668 271244 --c;
8669
8670
4/4
✓ Branch 0 taken 81892 times.
✓ Branch 1 taken 189352 times.
✓ Branch 2 taken 178175 times.
✓ Branch 3 taken 93069 times.
271244 if(c<0 && step<zslongToFix(dstep*100))
8671 {
8672 93069 step+=zslongToFix(dmisc3*100);
8673 93069 }
8674
8675 271244 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8676
8677
2/2
✓ Branch 0 taken 270922 times.
✓ Branch 1 taken 322 times.
271244 if(x<=16-nb) clk3=right;
8678
8679
2/2
✓ Branch 0 taken 270702 times.
✓ Branch 1 taken 542 times.
271244 if(x>=224+nb) clk3=left;
8680
8681 271244 x += (clk3==left) ? -1 : 1;
8682
8683
4/4
✓ Branch 0 taken 15373 times.
✓ Branch 1 taken 255871 times.
✓ Branch 2 taken 4984 times.
✓ Branch 3 taken 250887 times.
271244 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
8684 {
8685
4/4
✓ Branch 0 taken 661 times.
✓ Branch 1 taken 9728 times.
✓ Branch 2 taken 484 times.
✓ Branch 3 taken 177 times.
20357 if(y>=144+nb && get_qr(qr_ENEMIESZAXIS))
8686 {
8687 177 step=0-step;
8688 177 y--;
8689 177 }
8690
2/2
✓ Branch 0 taken 2320 times.
✓ Branch 1 taken 7892 times.
10212 else if(zc_oldrand()%dmisc2) //land and wait
8691 {
8692 7892 clk=misc=0;
8693 7892 } //land and jump again
8694 else
8695 {
8696 2320 misc=1;
8697 2320 clk2=0;
8698 }
8699 10389 }
8700
8701 261276 break;
8702 } // switch
8703 788531 }
8704
8705
4/4
✓ Branch 0 taken 333134 times.
✓ Branch 1 taken 551254 times.
✓ Branch 2 taken 226451 times.
✓ Branch 3 taken 106683 times.
884388 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8706 {
8707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106683 times.
106683 if (moveflags & FLAG_USE_FAKE_Z)
8708 {
8709 int32_t tempy = floor_y;
8710 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8711 floor_y = y;
8712 y=tempy-fakez;
8713 old_y = y;
8714 }
8715 else
8716 {
8717 106683 int32_t tempy = floor_y;
8718
6/6
✓ Branch 0 taken 53507 times.
✓ Branch 1 taken 53176 times.
✓ Branch 2 taken 100927 times.
✓ Branch 3 taken 5756 times.
✓ Branch 4 taken 49170 times.
✓ Branch 5 taken 51757 times.
106683 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8719 106683 floor_y = y;
8720 106683 y=tempy-z;
8721 106683 old_y = y;
8722 }
8723 106683 }
8724
8725
4/4
✓ Branch 0 taken 7005 times.
✓ Branch 1 taken 877383 times.
✓ Branch 2 taken 1407 times.
✓ Branch 3 taken 5598 times.
884388 if(stunclk && (clk&31)==1)
8726 5598 clk=0;
8727
8728 884388 return enemy::animate(index);
8729 903407 }
8730
8731 330586 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8732 {
8733
5/6
✓ Branch 0 taken 161030 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 161030 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 136696 times.
✓ Branch 5 taken 24334 times.
330586 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8734 24334 return;
8735
8736 306252 int32_t tempy=yofs;
8737 306252 int32_t fdiv = frate/4;
8738
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8739
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8740 306252 efrate:((clk>=(frate>>1))?1:0);
8741 306252 flip = 0;
8742 306252 shadowtile = wpnsbuf[spr_shadow].tile;
8743
8744
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 if(get_qr(qr_NEWENEMYTILES))
8745 {
8746
2/2
✓ Branch 0 taken 200675 times.
✓ Branch 1 taken 105577 times.
306252 if(misc==0)
8747 {
8748 105577 shadowtile+=f2;
8749 105577 }
8750
2/2
✓ Branch 0 taken 91502 times.
✓ Branch 1 taken 109173 times.
200675 else if(misc!=1)
8751 109173 shadowtile+=2;
8752 306252 }
8753 else
8754 {
8755 if(misc==0)
8756 {
8757 shadowtile += f2 ? 1 : 0;
8758 }
8759 else if(misc!=1)
8760 {
8761 ++shadowtile;
8762 }
8763 }
8764
8765 306252 yofs+=8;
8766
8767
4/4
✓ Branch 0 taken 136696 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 84452 times.
✓ Branch 3 taken 52244 times.
306252 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8768 {
8769
6/6
✓ Branch 0 taken 26557 times.
✓ Branch 1 taken 25687 times.
✓ Branch 2 taken 48843 times.
✓ Branch 3 taken 3401 times.
✓ Branch 4 taken 24406 times.
✓ Branch 5 taken 24437 times.
52244 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8770 52244 }
8771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306252 times.
306252 if(!shadow_overpit(this))
8772 306252 enemy::drawshadow(dest,translucent);
8773 306252 yofs=tempy;
8774 330586 }
8775
8776 1500560 void eTektite::draw(BITMAP *dest)
8777 {
8778 1500560 update_enemy_frame();
8779 1500560 enemy::draw(dest);
8780 1500560 }
8781
8782 413 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8783 413 {
8784
2/4
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
413 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8785 413 superman=1;
8786 413 dir=8;
8787 413 hxofs=1000;
8788 413 mainguy=false;
8789 413 count_enemy=false;
8790
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8791 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8792 // al_trace("Enemy txsz:%i\n", txsz);
8793
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
8794
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
8795
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
8796
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
8797
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
8798
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
8799 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8800
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
8801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8802 {
8803 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
8804 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8805 }
8806
8807
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
8808 413 }
8809
8810 228794 bool eItemFairy::animate(int32_t index)
8811 {
8812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228794 times.
228794 if(switch_hooked) return enemy::animate(index);
8813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228794 times.
228794 if(dying)
8814 return Dead(index);
8815
8816 //if(clk>32)
8817 228794 misc=1;
8818 228794 bool w=watch;
8819 228794 watch=false;
8820 228794 variable_walk_8(misc?3:0,0,8,spw_floater);
8821 228794 watch=w;
8822
8823
2/2
✓ Branch 0 taken 1107 times.
✓ Branch 1 taken 227687 times.
228794 if(clk==0)
8824 {
8825 1107 removearmos(x,y,ffcactivated);
8826 1107 }
8827
8828 228794 return enemy::animate(index);
8829 228794 }
8830
8831 458954 void eItemFairy::draw(BITMAP *dest)
8832 {
8833 //these are here to bypass compiler warnings about unused arguments
8834 458954 dest=dest;
8835 458954 }
8836
8837 1048 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8838 1048 {
8839 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8840
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✓ Branch 2 taken 1048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1048 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1048 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1048 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1048 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1048 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1048 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1048 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1048 times.
✗ Branch 19 not taken.
1048 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8841 1048 dir=8;
8842 1048 movestatus=1;
8843 1048 clk=0;
8844
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 step=0;
8845 //nets+720;
8846 1048 SIZEflags = d->SIZEflags;
8847
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8848 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8849 // al_trace("Enemy txsz:%i\n", txsz);
8850
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8851
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8852
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8853
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8854
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8855
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8856 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8857
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8859 {
8860 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8861 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8862 }
8863
8864
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8865 1048 }
8866
8867 300264 bool ePeahat::animate(int32_t index)
8868 {
8869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300264 times.
300264 if(switch_hooked) return enemy::animate(index);
8870
2/4
✓ Branch 0 taken 300264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 300264 times.
300264 if(fallclk||drownclk) return enemy::animate(index);
8871
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 300186 times.
300264 if(slide())
8872 {
8873 78 return false;
8874 }
8875
8876
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 299672 times.
300186 if(dying)
8877 514 return Dead(index);
8878
8879
2/2
✓ Branch 0 taken 297855 times.
✓ Branch 1 taken 1817 times.
299672 if(clk==0)
8880 {
8881 1817 removearmos(x,y,ffcactivated);
8882 1817 }
8883
8884
4/4
✓ Branch 0 taken 296892 times.
✓ Branch 1 taken 2780 times.
✓ Branch 2 taken 144455 times.
✓ Branch 3 taken 152437 times.
299672 if(stunclk==0 && clk>96)
8885 152437 misc=1;
8886
8887
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 297270 times.
299672 if(!watch)
8888
2/2
✓ Branch 0 taken 197329 times.
✓ Branch 1 taken 99941 times.
297270 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8889
8890
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 199654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
299672 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8891 {
8892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100018 times.
100018 if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8893 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8894 100018 }
8895
8896
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 297270 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
299672 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8897 1634 superman=0;
8898 else
8899
2/2
✓ Branch 0 taken 6888 times.
✓ Branch 1 taken 291150 times.
298038 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8900 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8901
2/2
✓ Branch 0 taken 196019 times.
✓ Branch 1 taken 103653 times.
299672 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8902 {
8903
2/2
✓ Branch 0 taken 193242 times.
✓ Branch 1 taken 2777 times.
196019 if ( stunclk ) --stunclk;
8904 196019 }
8905 103653 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8906 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8907
8908
8909
2/2
✓ Branch 0 taken 299448 times.
✓ Branch 1 taken 224 times.
299672 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8910
8911 299672 return enemy::animate(index);
8912 300264 }
8913
8914 126460 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8915 {
8916 126460 int32_t tempy=yofs;
8917 126460 flip = 0;
8918 126460 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8919
8920
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 38371 times.
126460 if(!get_qr(qr_ENEMIESZAXIS))
8921 {
8922 38371 yofs+=8;
8923 38371 yofs+=int32_t(step/zslongToFix(dstep*10));
8924 38371 }
8925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126460 times.
126460 if(!shadow_overpit(this))
8926 126460 enemy::drawshadow(dest,translucent);
8927 126460 yofs=tempy;
8928 126460 }
8929
8930 694948 void ePeahat::draw(BITMAP *dest)
8931 {
8932 694948 update_enemy_frame();
8933 694948 enemy::draw(dest);
8934 694948 }
8935
8936 1383 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8937 {
8938 1383 int32_t wpnId = w->id;
8939 1383 int32_t enemyHitWeapon = w->parentitem;
8940
8941
3/6
✓ Branch 0 taken 1383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1383 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1383 times.
1383 if(dying || clk<0 || hclk>0)
8942 return 0;
8943
8944
4/4
✓ Branch 0 taken 1186 times.
✓ Branch 1 taken 197 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 129 times.
1542 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8945 // fire boomerang, for nailing peahats
8946
4/6
✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1027 times.
✓ Branch 3 taken 159 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 159 times.
1186 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8947 1156 return 0;
8948
8949 // Time for a kludge...
8950 227 int32_t s = superman;
8951 227 superman = 0;
8952 227 int32_t ret = enemy::takehit(w,realweap);
8953 227 superman = s;
8954
8955 // Anyway...
8956
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 141 times.
227 if(stunclk == 160)
8957 {
8958 141 clk2=0;
8959 141 movestatus=0;
8960 141 misc=0;
8961 141 clk=0;
8962 141 step=0;
8963 141 }
8964
8965 227 return ret;
8966 1383 }
8967
8968 // auomatically kill off enemy (for rooms with ringleaders)
8969 void ePeahat::kickbucket()
8970 {
8971 hp=-1000; // don't call death_sfx()
8972 }
8973
8974 1694 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8975 1694 {
8976 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8977
2/2
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 941 times.
1694 if(dmisc1==0)
8978 {
8979 941 misc=-1; //Line of Sight leevers
8980 941 clk-=16;
8981 941 }
8982 1694 clk3 = 0;
8983 //nets+1460;
8984 1694 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8985 1694 submerged = false;
8986 1694 SIZEflags = d->SIZEflags;
8987
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8988 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8989 // al_trace("Enemy txsz:%i\n", txsz);
8990
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8992
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8993
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8994
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8995
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8996 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8997
1/4
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8999 {
9000 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9001 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9002 }
9003
9004
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9005 1694 }
9006
9007 bool eLeever::isSubmerged() const
9008 {
9009 Z_scripterrlog("misc is: %d\n", misc);
9010 return misc <= 0;
9011
9012 }
9013
9014 499943 bool eLeever::animate(int32_t index)
9015 {
9016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 499943 times.
499943 if(switch_hooked) return enemy::animate(index);
9017
2/4
✓ Branch 0 taken 499943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 499943 times.
499943 if(fallclk||drownclk)
9018 {
9019 return enemy::animate(index);
9020 }
9021
2/2
✓ Branch 0 taken 16506 times.
✓ Branch 1 taken 483437 times.
499943 if(dying)
9022 16506 return Dead(index);
9023
9024
2/2
✓ Branch 0 taken 463097 times.
✓ Branch 1 taken 20340 times.
483437 if(clk==0)
9025 {
9026 20340 removearmos(x,y,ffcactivated);
9027 20340 }
9028
9029
4/4
✓ Branch 0 taken 393192 times.
✓ Branch 1 taken 90245 times.
✓ Branch 2 taken 2529 times.
✓ Branch 3 taken 390663 times.
483437 if(clk>=0 && !slide())
9030 {
9031 // switch(d->misc1)
9032
2/2
✓ Branch 0 taken 156396 times.
✓ Branch 1 taken 234267 times.
390663 switch(dmisc1)
9033 {
9034 case 0: //line of sight
9035 case 2:
9036
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✓ Branch 2 taken 17136 times.
✓ Branch 3 taken 15898 times.
✓ Branch 4 taken 7088 times.
✓ Branch 5 taken 43977 times.
✓ Branch 6 taken 1832 times.
✓ Branch 7 taken 2915 times.
156396 switch(misc) //is this leever active
9037 {
9038 case -1: //submerged
9039 {
9040
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
67550 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
9041
4/4
✓ Branch 0 taken 7609 times.
✓ Branch 1 taken 59941 times.
✓ Branch 2 taken 7582 times.
✓ Branch 3 taken 27 times.
67550 if((dmisc1==2)&&(zc_oldrand()&255))
9042 {
9043 7582 break;
9044 }
9045
9046 59968 int32_t active=0;
9047
9048
2/2
✓ Branch 0 taken 424896 times.
✓ Branch 1 taken 59968 times.
484864 for(int32_t i=0; i<guys.Count(); i++)
9049 {
9050
4/4
✓ Branch 0 taken 348604 times.
✓ Branch 1 taken 76292 times.
✓ Branch 2 taken 229810 times.
✓ Branch 3 taken 118794 times.
424896 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
9051 {
9052 118794 ++active;
9053 118794 }
9054 424896 }
9055
9056
2/2
✓ Branch 0 taken 59147 times.
✓ Branch 1 taken 821 times.
59968 if(active<((dmisc1==2)?1:2))
9057 {
9058 821 misc=0; //activate this one
9059 821 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
9060 821 }
9061 }
9062 59968 break;
9063
9064 case 0:
9065 {
9066
9067
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17136 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9068 {
9069 misc=1;
9070 clk2=0;
9071 }
9072
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 17100 times.
17136 else if (clk3<=0)
9073 {
9074 36 misc = -1;
9075 36 break;
9076 }
9077 17100 int32_t s=0;
9078
9079
2/2
✓ Branch 0 taken 112208 times.
✓ Branch 1 taken 17100 times.
129308 for(int32_t i=0; i<guys.Count(); i++)
9080 {
9081
4/4
✓ Branch 0 taken 74011 times.
✓ Branch 1 taken 38197 times.
✓ Branch 2 taken 71849 times.
✓ Branch 3 taken 2162 times.
112208 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
9082 {
9083 2162 ++s;
9084 2162 }
9085 112208 }
9086
9087
2/2
✓ Branch 0 taken 2162 times.
✓ Branch 1 taken 14938 times.
17100 if(s>0)
9088 {
9089 2162 break;
9090 }
9091
9092 14938 int32_t d2=zc_oldrand()&1;
9093
9094
2/2
✓ Branch 0 taken 5336 times.
✓ Branch 1 taken 9602 times.
14938 if(HeroDir()>=left)
9095 {
9096 9602 d2+=2;
9097 9602 }
9098
9099
4/4
✓ Branch 0 taken 14295 times.
✓ Branch 1 taken 643 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 13995 times.
14938 if(canplace(d2) || canplace(d2^1))
9100 {
9101 943 misc=1;
9102 943 clk2=0;
9103 943 clk=0;
9104 943 }
9105 }
9106 14938 break;
9107
9108 case 1:
9109
9110
3/8
✓ Branch 0 taken 14970 times.
✓ Branch 1 taken 928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14970 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15898 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9111
9112 15898 break;
9113
9114 case 2:
9115
9116
3/8
✓ Branch 0 taken 6227 times.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6227 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7088 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9117
9118 7088 break;
9119
9120 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9121 case 3:
9122
9123
5/6
✓ Branch 0 taken 41679 times.
✓ Branch 1 taken 2298 times.
✓ Branch 2 taken 41679 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2066 times.
✓ Branch 5 taken 39613 times.
43977 if(stunclk || frozenclock || watch) break;
9124
9125
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 39534 times.
39613 if(scored) dir^=1;
9126
9127
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 39402 times.
39613 if(!canmove(dir,false)) misc=4;
9128 39402 else move(zslongToFix(dstep*100));
9129
9130 39613 break;
9131
9132 case 4:
9133
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1832 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9134
2/2
✓ Branch 0 taken 1635 times.
✓ Branch 1 taken 197 times.
1832 if(--clk2<=16)
9135 {
9136 197 misc=5;
9137 197 clk=8;
9138 197 }
9139
9140 1832 break;
9141
9142 case 5:
9143
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2915 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2915 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9144
2/2
✓ Branch 0 taken 2740 times.
✓ Branch 1 taken 175 times.
2915 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9145
9146 2915 break;
9147 } // switch(misc)
9148
9149 156396 break;
9150
9151 default: //random
9152 // step=d->misc3/100.0;
9153
9154 234267 step=zslongToFix(dmisc3*100);
9155
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
234267 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9156 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9157 {
9158 if (clk2 < 48) clk2+=2;
9159 if (clk2 >= 300) clk2-=2;
9160 }
9161
9162
2/2
✓ Branch 0 taken 27519 times.
✓ Branch 1 taken 206748 times.
234267 if(clk2<32) misc=1;
9163
2/2
✓ Branch 0 taken 13816 times.
✓ Branch 1 taken 192932 times.
206748 else if(clk2<48) misc=2;
9164
2/2
✓ Branch 0 taken 140831 times.
✓ Branch 1 taken 52101 times.
192932 else if(clk2<300)
9165 {
9166 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9167 {
9168 fix_coords();
9169 }*/
9170 140831 misc=3;
9171 140831 step = zslongToFix(dstep*100);
9172 140831 }
9173
2/2
✓ Branch 0 taken 4801 times.
✓ Branch 1 taken 47300 times.
52101 else if(clk2<316) misc=2;
9174
2/2
✓ Branch 0 taken 23641 times.
✓ Branch 1 taken 23659 times.
47300 else if(clk2<412) misc=1;
9175
2/2
✓ Branch 0 taken 23490 times.
✓ Branch 1 taken 169 times.
23659 else if(clk2<540)
9176 {
9177 23490 misc=0;
9178 23490 step=0;
9179 23490 }
9180 169 else clk2=0;
9181
9182
2/2
✓ Branch 0 taken 233418 times.
✓ Branch 1 taken 849 times.
234267 if(clk2==48) clk=0;
9183
9184 // variable_walk(d->rate, d->homing, 0);
9185 234267 variable_walk(rate, homing, 0);
9186 234267 } // switch(dmisc1)
9187 390663 }
9188
9189 483437 hxofs=(misc>=2)?0:1000;
9190 483437 return enemy::animate(index);
9191 499943 }
9192
9193 29233 bool eLeever::canplace(int32_t d2)
9194 {
9195 29233 int32_t nx=HeroX();
9196 29233 int32_t ny=HeroY();
9197
9198
2/2
✓ Branch 0 taken 10404 times.
✓ Branch 1 taken 18829 times.
29233 if(d2<left) ny&=0xF0;
9199 18829 else nx&=0xF0;
9200
9201
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5173 times.
✓ Branch 2 taken 5231 times.
✓ Branch 3 taken 9395 times.
✓ Branch 4 taken 9434 times.
29233 switch(d2)
9202 {
9203 // case up: ny-=((d->misc1==0)?32:48); break;
9204 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
9205 // case left: nx-=((d->misc1==0)?32:48); break;
9206 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
9207 case up:
9208
2/2
✓ Branch 0 taken 5145 times.
✓ Branch 1 taken 28 times.
5173 ny-=((dmisc1==0||dmisc1==2)?32:48);
9209 5173 break;
9210
9211 case down:
9212
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 5200 times.
5231 ny+=((dmisc1==0||dmisc1==2)?32:48);
9213
9214
4/4
✓ Branch 0 taken 2757 times.
✓ Branch 1 taken 2474 times.
✓ Branch 2 taken 2748 times.
✓ Branch 3 taken 9 times.
5231 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9215
9216 5231 break;
9217
9218 case left:
9219
2/2
✓ Branch 0 taken 8795 times.
✓ Branch 1 taken 600 times.
9395 nx-=((dmisc1==0||dmisc1==2)?32:48);
9220 9395 break;
9221
9222 case right:
9223
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 8839 times.
9434 nx+=((dmisc1==0||dmisc1==2)?32:48);
9224
9225
4/4
✓ Branch 0 taken 6054 times.
✓ Branch 1 taken 3380 times.
✓ Branch 2 taken 5499 times.
✓ Branch 3 taken 555 times.
9434 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9226
9227 9434 break;
9228 }
9229
9230
4/4
✓ Branch 0 taken 10020 times.
✓ Branch 1 taken 19213 times.
✓ Branch 2 taken 4483 times.
✓ Branch 3 taken 5537 times.
29233 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9231 23696 return false;
9232
9233
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 5098 times.
5537 if(d2>=left)
9234
4/4
✓ Branch 0 taken 2481 times.
✓ Branch 1 taken 2617 times.
✓ Branch 2 taken 4594 times.
✓ Branch 3 taken 504 times.
5098 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9235 4594 return false;
9236
9237 943 x=nx;
9238 943 y=ny;
9239 943 dir=d2^1;
9240 943 return true;
9241 29233 }
9242
9243 500779 void eLeever::draw(BITMAP *dest)
9244 {
9245 // cs=d->cset;
9246 500779 cs=dcset;
9247 500779 update_enemy_frame();
9248
2/4
✓ Branch 0 taken 500779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500779 times.
500779 if(!fallclk&&!drownclk)
9249 {
9250
2/2
✓ Branch 0 taken 301145 times.
✓ Branch 1 taken 199634 times.
500779 switch(misc)
9251 {
9252 case -1:
9253 case 0:
9254 199634 return;
9255 }
9256 301145 }
9257
9258 301145 enemy::draw(dest);
9259 500779 }
9260
9261 523 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9262 523 {
9263 //zprint2("eWallM::eWallM\n");
9264 523 hashero=false;
9265 //nets+1000;
9266 523 SIZEflags = d->SIZEflags;
9267
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9268 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9269 // al_trace("Enemy txsz:%i\n", txsz);
9270
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9272
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9273
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9274
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9275
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9276 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9277
1/4
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9279 {
9280 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9281 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9282 }
9283
9284
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9285 523 }
9286
9287 321974 bool eWallM::animate(int32_t index)
9288 {
9289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 321974 times.
321974 if(switch_hooked) return enemy::animate(index);
9290
2/4
✓ Branch 0 taken 321974 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 321974 times.
321974 if(fallclk||drownclk)
9291 {
9292 return enemy::animate(index);
9293 }
9294
2/2
✓ Branch 0 taken 6282 times.
✓ Branch 1 taken 315692 times.
321974 if(dying)
9295 6282 return Dead(index);
9296
9297
2/2
✓ Branch 0 taken 295632 times.
✓ Branch 1 taken 20060 times.
315692 if(clk==0)
9298 {
9299 20060 removearmos(x,y,ffcactivated);
9300 20060 }
9301
9302 315692 hxofs=1000;
9303
2/2
✓ Branch 0 taken 81640 times.
✓ Branch 1 taken 234052 times.
315692 if(misc==0) //inside wall, ready to spawn?
9304 {
9305 //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk);
9306 //zprint2("frame is: %d\n",frame);
9307 //zprint2("wallm_load_clk is: %d\n",wallm_load_clk);
9308
4/4
✓ Branch 0 taken 154566 times.
✓ Branch 1 taken 79486 times.
✓ Branch 2 taken 9024 times.
✓ Branch 3 taken 145542 times.
234052 if(frame-wallm_load_clk>80 && clk>=0)
9309 {
9310 //zprint2("getting wall\n");
9311 145542 int32_t wall=hero_on_wall();
9312 //zprint2("Wallmaster wall is %d\n",wall);
9313 145542 int32_t wallm_cnt=0;
9314
9315
2/2
✓ Branch 0 taken 1108757 times.
✓ Branch 1 taken 145542 times.
1254299 for(int32_t i=0; i<guys.Count(); i++)
9316
2/2
✓ Branch 0 taken 421543 times.
✓ Branch 1 taken 687214 times.
1795971 if(((enemy*)guys.spr(i))->family==eeWALLM)
9317 {
9318 687214 int32_t m=((enemy*)guys.spr(i))->misc;
9319
9320
4/4
✓ Branch 0 taken 32180 times.
✓ Branch 1 taken 655034 times.
✓ Branch 2 taken 20369 times.
✓ Branch 3 taken 11811 times.
687214 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9321 {
9322 11811 ++wallm_cnt;
9323 11811 }
9324 687214 }
9325
9326
2/2
✓ Branch 0 taken 145029 times.
✓ Branch 1 taken 513 times.
145542 if(wall>0)
9327 {
9328 513 --wall;
9329 513 misc=1; //emerging from the wall?
9330 //zprint2("Wallmaster is emerging\n");
9331 513 clk2=0;
9332 513 clk3=wall^1;
9333 513 wallm_load_clk=frame;
9334
9335
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 201 times.
513 if(wall<=down)
9336 {
9337
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 258 times.
312 if(HeroDir()==left)
9338 54 dir=right;
9339 else
9340 258 dir=left;
9341 312 }
9342 else
9343 {
9344
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 162 times.
201 if(HeroDir()==up)
9345 39 dir=down;
9346 else
9347 162 dir=up;
9348 }
9349
9350
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 132 times.
✓ Branch 4 taken 69 times.
513 switch(wall)
9351 {
9352 case up:
9353 152 y=0;
9354 152 break;
9355
9356 case down:
9357 160 y=160;
9358 160 break;
9359
9360 case left:
9361 132 x=0;
9362 132 break;
9363
9364 case right:
9365 69 x=240;
9366 69 break;
9367 }
9368
9369 //zprint2("Wallmaster (p1) x is %d\n",x);
9370 //zprint2("Wallmaster (p1) y is %d\n",y);
9371
9372
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 54 times.
513 switch(dir)
9373 {
9374 case up:
9375 162 y=(HeroY()+48-(wallm_cnt&1)*12);
9376 162 flip=wall&1;
9377 162 break;
9378
9379 case down:
9380 39 y=(HeroY()-48+(wallm_cnt&1)*12);
9381 39 flip=((wall&1)^1)+2;
9382 39 break;
9383
9384 case left:
9385 258 x=(HeroX()+48-(wallm_cnt&1)*12);
9386 258 flip=(wall==up?2:0)+1;
9387 258 break;
9388
9389 case right:
9390 54 x=(HeroX()-48+(wallm_cnt&1)*12);
9391 54 flip=(wall==up?2:0);
9392 54 break;
9393 }
9394
9395 //zprint2("Wallmaster (p2) x is %d\n",x);
9396 //zprint2("Wallmaster (p2) y is %d\n",y);
9397 513 }
9398 145542 }
9399 234052 }
9400 else
9401 81640 wallm_crawl();
9402
9403 315692 return enemy::animate(index);
9404 321974 }
9405
9406 81640 void eWallM::wallm_crawl()
9407 {
9408 81640 bool w=watch;
9409 81640 hxofs=0;
9410
9411
2/2
✓ Branch 0 taken 591 times.
✓ Branch 1 taken 81049 times.
81640 if(slide())
9412 {
9413 591 return;
9414 }
9415
9416 // if(dying || watch || (!hashero && stunclk))
9417
6/8
✓ Branch 0 taken 81049 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80760 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 66702 times.
✓ Branch 5 taken 14058 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 66702 times.
81049 if(dying || (!hashero && ( stunclk || frozenclock )))
9418 {
9419 14058 return;
9420 }
9421
9422 66991 watch=false;
9423 66991 ++clk2;
9424 // Misc1: slightly different movement
9425 //zprint2("wallmaster crawl\n");
9426 //zprint2("wallmaster tmpdstep is %d\n",tmpdstep);
9427 66991 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9428
9429 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9430 //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc);
9431 //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4);
9432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66991 times.
66991 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9433 //zprint2("wallmaster crawl misc is: %d\n", misc);
9434
5/6
✓ Branch 0 taken 5942 times.
✓ Branch 1 taken 61049 times.
✓ Branch 2 taken 4472 times.
✓ Branch 3 taken 1470 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4472 times.
66991 if(w&&misc>=3&&misc<=5)
9435 {
9436 4472 --clk2;
9437 4472 }
9438
9439
4/4
✓ Branch 0 taken 28236 times.
✓ Branch 1 taken 31313 times.
✓ Branch 2 taken 7328 times.
✓ Branch 3 taken 114 times.
66991 switch(misc)
9440 {
9441 case 1:
9442 case 2:
9443 31313 zc_swap(dir,clk3);
9444 31313 move(step);
9445 31313 zc_swap(dir,clk3);
9446 31313 break;
9447
9448 case 3:
9449 case 4:
9450 case 5:
9451
2/2
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 23764 times.
28236 if(w)
9452 {
9453 4472 watch=w;
9454 4472 return;
9455 }
9456
9457 23764 move(step);
9458 23764 break;
9459
9460 case 6:
9461 case 7:
9462 7328 zc_swap(dir,clk3);
9463 7328 dir^=1;
9464 7328 move(step);
9465 7328 dir^=1;
9466 7328 zc_swap(dir,clk3);
9467 7328 break;
9468
9469 default:
9470 114 misc=0;
9471 114 break;
9472 }
9473
9474 62519 watch=w;
9475 81640 }
9476
9477 3 void eWallM::grabhero()
9478 {
9479 3 hashero=true;
9480 3 superman=1;
9481 3 }
9482
9483 322782 void eWallM::draw(BITMAP *dest)
9484 {
9485 322782 dummy_bool[1]=hashero;
9486 322782 update_enemy_frame();
9487
9488
4/6
✓ Branch 0 taken 234569 times.
✓ Branch 1 taken 88213 times.
✓ Branch 2 taken 234569 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 234569 times.
322782 if(misc>0 || fallclk||drownclk)
9489 {
9490 88213 masked_draw(dest,16,playing_field_offset+16,224,144);
9491 88213 }
9492
9493 // enemy::draw(dest);
9494 // tile = clk&8 ? 128:129;
9495 322782 }
9496
9497 bool eWallM::isSubmerged() const
9498 {
9499 return ( !misc );
9500 }
9501
9502 742 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9503 742 {
9504
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 ox=x; //original x
9505
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 oy=y; //original y
9506
2/2
✓ Branch 0 taken 676 times.
✓ Branch 1 taken 66 times.
742 if(get_qr(qr_TRAPPOSFIX))
9507 {
9508
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
66 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9509 66 }
9510
9511 742 mainguy=false;
9512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
742 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9513 //nets+420;
9514 742 dummy_int[1]=0;
9515 742 SIZEflags = d->SIZEflags;
9516
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9517 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9518 // al_trace("Enemy txsz:%i\n", txsz);
9519
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9521
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9522
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9523
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9524
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9525 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9528 {
9529 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9530 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9531 }
9532
9533
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9534 742 }
9535
9536 534456 bool eTrap::animate(int32_t index)
9537 {
9538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 534456 times.
534456 if(switch_hooked) return enemy::animate(index);
9539
2/4
✓ Branch 0 taken 534456 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 534456 times.
534456 if(fallclk||drownclk) return enemy::animate(index);
9540
2/2
✓ Branch 0 taken 524072 times.
✓ Branch 1 taken 10384 times.
534456 if(clk<0)
9541 10384 return enemy::animate(index);
9542
9543
2/2
✓ Branch 0 taken 490954 times.
✓ Branch 1 taken 33118 times.
524072 if(clk==0)
9544 {
9545 33118 removearmos(x,y,ffcactivated);
9546 33118 }
9547
9548
2/2
✓ Branch 0 taken 142952 times.
✓ Branch 1 taken 381120 times.
524072 if(misc==0) // waiting
9549 {
9550 381120 ox = x;
9551 381120 oy = y;
9552 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9553 381120 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9554
9555
4/4
✓ Branch 0 taken 127495 times.
✓ Branch 1 taken 253625 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 53982 times.
381120 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9556 {
9557 53982 dir=down;
9558 53982 }
9559
4/4
✓ Branch 0 taken 220423 times.
✓ Branch 1 taken 106715 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 146910 times.
327138 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9560 {
9561 146910 dir=right;
9562 146910 }
9563
4/4
✓ Branch 0 taken 112988 times.
✓ Branch 1 taken 67240 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 39475 times.
180228 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9564 {
9565 39475 dir=up;
9566 39475 }
9567 else
9568 {
9569 140753 dir=left;
9570 }
9571
9572 381120 int32_t d2=lined_up(15,true);
9573
9574
4/4
✓ Branch 0 taken 135666 times.
✓ Branch 1 taken 245454 times.
✓ Branch 2 taken 684811 times.
✓ Branch 3 taken 303691 times.
615292 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9575
2/2
✓ Branch 0 taken 129243 times.
✓ Branch 1 taken 174448 times.
303691 ((d2>down) && (dmisc1==2)) ||
9576
2/2
✓ Branch 0 taken 118337 times.
✓ Branch 1 taken 70965 times.
174448 ((d2>right) && (!dmisc1)) ||
9577
2/2
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 65634 times.
189302 ((d2<l_up) && (dmisc1==4)) ||
9578
3/4
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 168538 times.
✓ Branch 2 taken 234172 times.
✗ Branch 3 not taken.
65634 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9579
3/4
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 65634 times.
✓ Branch 2 taken 234172 times.
✗ Branch 3 not taken.
168538 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9580 {
9581 1516570 d2=-1;
9582 1516570 }
9583
9584
4/4
✓ Branch 0 taken 11339 times.
✓ Branch 1 taken 201243 times.
✓ Branch 2 taken 10273 times.
✓ Branch 3 taken 1066 times.
212582 if(d2!=-1 && trapmove(d2))
9585 {
9586 1066 dir=d2;
9587 1066 misc=1;
9588 1066 clk2=(dir==down)?3:0;
9589 1066 }
9590 212582 }
9591
9592
2/2
✓ Branch 0 taken 316873 times.
✓ Branch 1 taken 38661 times.
355534 if(misc==1) // charging
9593 {
9594 38661 clk2=(clk2+1)&3;
9595 38661 step=(clk2==3)?1:2;
9596
9597
4/4
✓ Branch 0 taken 38531 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 860 times.
✓ Branch 3 taken 37671 times.
38661 if(!trapmove(dir) || clip())
9598 {
9599 990 misc=2;
9600
9601
1/2
✓ Branch 0 taken 990 times.
✗ Branch 1 not taken.
990 if(dir<l_up)
9602 {
9603 990 dir=dir^1;
9604 990 }
9605 else
9606 {
9607 dir=dir^3;
9608 }
9609 990 }
9610 else
9611 {
9612 37671 sprite::move(step);
9613 }
9614 38661 }
9615
9616
2/2
✓ Branch 0 taken 249187 times.
✓ Branch 1 taken 106347 times.
355534 if(misc==2) // retreating
9617 {
9618 106347 step=(++clk2&1)?1:0;
9619
9620
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 17320 times.
✓ Branch 2 taken 39848 times.
✓ Branch 3 taken 11903 times.
✓ Branch 4 taken 37276 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106347 switch(dir)
9621 {
9622 case up:
9623
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 17181 times.
17320 if(int32_t(y)<=oy) goto trap_rest;
9624 17181 else sprite::move(step);
9625
9626 17181 break;
9627
9628 case left:
9629
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 39620 times.
39848 if(int32_t(x)<=ox) goto trap_rest;
9630 39620 else sprite::move(step);
9631
9632 39620 break;
9633
9634 case down:
9635
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 11791 times.
11903 if(int32_t(y)>=oy) goto trap_rest;
9636 11791 else sprite::move(step);
9637
9638 11791 break;
9639
9640 case right:
9641
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 37049 times.
37276 if(int32_t(x)>=ox) goto trap_rest;
9642 37049 else sprite::move(step);
9643
9644 37049 break;
9645
9646 case l_up:
9647 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9648 else sprite::move(step);
9649
9650 break;
9651
9652 case r_up:
9653 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9654 else sprite::move(step);
9655
9656 break;
9657
9658 case l_down:
9659 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9660 else sprite::move(step);
9661
9662 break;
9663
9664 case r_down:
9665 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9666 else sprite::move(step);
9667
9668 break;
9669 trap_rest:
9670 {
9671 706 x=ox;
9672 706 y=oy;
9673 706 misc=0;
9674 }
9675 706 }
9676 106347 }
9677
9678 355534 return enemy::animate(index);
9679 365918 }
9680
9681 50000 bool eTrap::trapmove(int32_t ndir)
9682 {
9683
2/2
✓ Branch 0 taken 35733 times.
✓ Branch 1 taken 14267 times.
50000 if(get_qr(qr_MEANTRAPS))
9684 {
9685
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 34393 times.
35733 if(tmpscr->flags2&fFLOATTRAPS)
9686 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9687
9688 34393 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9689 }
9690
9691
6/6
✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 8023 times.
✓ Branch 2 taken 4374 times.
✓ Branch 3 taken 1870 times.
✓ Branch 4 taken 1608 times.
✓ Branch 5 taken 2766 times.
14267 if(oy==80 && !(ndir==left || ndir == right))
9692 2766 return false;
9693
9694
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11501 if(ox==128 && !(ndir==up || ndir==down))
9695 return false;
9696
9697
3/4
✓ Branch 0 taken 4333 times.
✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 4333 times.
✗ Branch 3 not taken.
11501 if(oy<80 && ndir==up)
9698 return false;
9699
9700
3/4
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 3690 times.
✗ Branch 3 not taken.
11501 if(oy>80 && ndir==down)
9701 return false;
9702
9703
4/4
✓ Branch 0 taken 5854 times.
✓ Branch 1 taken 5647 times.
✓ Branch 2 taken 5136 times.
✓ Branch 3 taken 718 times.
11501 if(ox<128 && ndir==left)
9704 718 return false;
9705
9706
4/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 5159 times.
✓ Branch 3 taken 488 times.
10783 if(ox>128 && ndir==right)
9707 488 return false;
9708
9709
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 2207 times.
✓ Branch 3 taken 2929 times.
✓ Branch 4 taken 2207 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy<80 && ndir==l_up)
9710 return false;
9711
9712
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 1809 times.
✓ Branch 3 taken 3327 times.
✓ Branch 4 taken 1809 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy>80 && ndir==l_down)
9713 return false;
9714
9715
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 2126 times.
✓ Branch 3 taken 3033 times.
✓ Branch 4 taken 2126 times.
✗ Branch 5 not taken.
10295 if(ox>128 && oy<80 && ndir==r_up)
9716 return false;
9717
9718
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 1881 times.
✓ Branch 3 taken 3278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1881 times.
10295 if(ox>128 && oy>80 && ndir==r_down)
9719 return false;
9720
9721 10295 return true;
9722 50000 }
9723
9724 38531 bool eTrap::clip()
9725 {
9726
2/2
✓ Branch 0 taken 33513 times.
✓ Branch 1 taken 5018 times.
38531 if(get_qr(qr_MEANPLACEDTRAPS))
9727 {
9728
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✓ Branch 2 taken 1926 times.
✓ Branch 3 taken 985 times.
✓ Branch 4 taken 1377 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5018 switch(dir)
9729 {
9730 case up:
9731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
730 if(y<=0) return true;
9732
9733 730 break;
9734
9735 case down:
9736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1926 times.
1926 if(y>=160) return true;
9737
9738 1926 break;
9739
9740 case left:
9741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985 times.
985 if(x<=0) return true;
9742
9743 985 break;
9744
9745 case right:
9746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377 times.
1377 if(x>=240) return true;
9747
9748 1377 break;
9749
9750 case l_up:
9751 if(y<=0||x<=0) return true;
9752
9753 break;
9754
9755 case l_down:
9756 if(y>=160||x<=0) return true;
9757
9758 break;
9759
9760 case r_up:
9761 if(y<=0||x>=240) return true;
9762
9763 break;
9764
9765 case r_down:
9766 if(y>=160||x>=240) return true;
9767
9768 break;
9769 }
9770
9771 5018 return false;
9772 }
9773 else
9774 {
9775
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3745 times.
✓ Branch 2 taken 4135 times.
✓ Branch 3 taken 12605 times.
✓ Branch 4 taken 13028 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
33513 switch(dir)
9776 {
9777 case up:
9778
4/4
✓ Branch 0 taken 3691 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 3546 times.
✓ Branch 3 taken 145 times.
3745 if(oy>80 && y<=86) return true;
9779
9780 3600 break;
9781
9782 case down:
9783
4/4
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 3903 times.
✓ Branch 3 taken 151 times.
4135 if(oy<80 && y>=80) return true;
9784
9785 3984 break;
9786
9787 case left:
9788
4/4
✓ Branch 0 taken 12515 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 12236 times.
✓ Branch 3 taken 279 times.
12605 if(ox>128 && x<=124) return true;
9789
9790 12326 break;
9791
9792 case right:
9793
3/4
✓ Branch 0 taken 13028 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12743 times.
✓ Branch 3 taken 285 times.
13028 if(ox<120 && x>=116) return true;
9794
9795 12743 break;
9796
9797 case l_up:
9798 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9799
9800 break;
9801
9802 case l_down:
9803 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9804
9805 break;
9806
9807 case r_up:
9808 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9809
9810 break;
9811
9812 case r_down:
9813 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9814
9815 break;
9816 }
9817
9818 32653 return false;
9819 }
9820 38531 }
9821
9822 537872 void eTrap::draw(BITMAP *dest)
9823 {
9824 537872 update_enemy_frame();
9825 537872 enemy::draw(dest);
9826 537872 }
9827
9828 2407 int32_t eTrap::takehit(weapon*,weapon*)
9829 {
9830 2407 return 0;
9831 }
9832
9833 147 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9834 147 {
9835 147 lasthit=-1;
9836 147 lasthitclk=0;
9837 147 mainguy=false;
9838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9839
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 step=2;
9840
3/6
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9841 {
9842
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
67 dir=(x<=112)?right:left;
9843 67 }
9844 else
9845 {
9846
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 dir=(y<=72)?down:up;
9847 }
9848
9849
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(get_qr(qr_TRAPPOSFIX))
9850 {
9851 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9852 }
9853
9854 //nets+((id==eTRAP_LR)?540:520);
9855 147 dummy_int[1]=0;
9856 147 SIZEflags = d->SIZEflags;
9857
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9858 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9859 // al_trace("Enemy txsz:%i\n", txsz);
9860
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9861
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9862
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9863
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9864
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9865
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9866 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9867
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9869 {
9870 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9871 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9872 }
9873
9874
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9875 147 }
9876
9877 85467 bool eTrap2::animate(int32_t index)
9878 {
9879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85467 times.
85467 if(switch_hooked) return enemy::animate(index);
9880
2/4
✓ Branch 0 taken 85467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 85467 times.
85467 if(fallclk||drownclk) return enemy::animate(index);
9881
2/2
✓ Branch 0 taken 83409 times.
✓ Branch 1 taken 2058 times.
85467 if(clk<0)
9882 2058 return enemy::animate(index);
9883
9884
2/2
✓ Branch 0 taken 5289 times.
✓ Branch 1 taken 78120 times.
83409 if(clk==0)
9885 {
9886 5289 removearmos(x,y,ffcactivated);
9887 5289 }
9888
9889
2/2
✓ Branch 0 taken 79017 times.
✓ Branch 1 taken 4392 times.
83409 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9890 {
9891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4392 times.
4392 if(lasthitclk>0)
9892 {
9893 --lasthitclk;
9894 }
9895 else
9896 {
9897 4392 lasthit=-1;
9898 }
9899
9900 4392 bool hitenemy=false;
9901
9902
2/2
✓ Branch 0 taken 57096 times.
✓ Branch 1 taken 4392 times.
61488 for(int32_t j=0; j<guys.Count(); j++)
9903 {
9904
3/4
✓ Branch 0 taken 52704 times.
✓ Branch 1 taken 4392 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52704 times.
57096 if((j!=index) && (lasthit!=j))
9905 {
9906
1/2
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
52704 if(hit(guys.spr(j)))
9907 {
9908 lasthit=j;
9909 lasthitclk=10;
9910 hitenemy=true;
9911 guys.spr(j)->lasthit=index;
9912 guys.spr(j)->lasthitclk=10;
9913 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9914 }
9915 52704 }
9916 57096 }
9917
9918
4/6
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 4344 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4344 times.
4392 if(!trapmove(dir) || clip() || hitenemy)
9919 {
9920
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(!trapmove(dir) || clip())
9921 {
9922 48 lasthit=-1;
9923 48 lasthitclk=0;
9924 48 }
9925
9926
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(get_qr(qr_MORESOUNDS))
9927 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9928
9929 48 dir=dir^1;
9930 48 }
9931
9932 4392 sprite::move(step);
9933 4392 }
9934 else
9935 {
9936
3/4
✓ Branch 0 taken 77234 times.
✓ Branch 1 taken 1783 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77234 times.
79017 if(!trapmove(dir) || clip())
9937 {
9938
1/2
✓ Branch 0 taken 1783 times.
✗ Branch 1 not taken.
1783 if(get_qr(qr_MORESOUNDS))
9939 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9940
9941 1783 dir=dir^1;
9942 1783 }
9943
9944 79017 sprite::move(step);
9945 }
9946
9947 83409 return enemy::animate(index);
9948 85467 }
9949
9950 83457 bool eTrap2::trapmove(int32_t ndir)
9951 {
9952
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 81579 times.
83457 if(tmpscr->flags2&fFLOATTRAPS)
9953 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9954
9955 81579 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9956 83457 }
9957
9958 81578 bool eTrap2::clip()
9959 {
9960
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 23387 times.
✓ Branch 2 taken 23376 times.
✓ Branch 3 taken 17291 times.
✓ Branch 4 taken 17524 times.
81578 switch(dir)
9961 {
9962 case up:
9963
1/2
✓ Branch 0 taken 23387 times.
✗ Branch 1 not taken.
23387 if(y<=0) return true;
9964
9965 23387 break;
9966
9967 case down:
9968
1/2
✓ Branch 0 taken 23376 times.
✗ Branch 1 not taken.
23376 if(y>=160) return true;
9969
9970 23376 break;
9971
9972 case left:
9973
1/2
✓ Branch 0 taken 17291 times.
✗ Branch 1 not taken.
17291 if(x<=0) return true;
9974
9975 17291 break;
9976
9977 case right:
9978
1/2
✓ Branch 0 taken 17524 times.
✗ Branch 1 not taken.
17524 if(x>=240) return true;
9979
9980 17524 break;
9981 }
9982
9983 81578 return false;
9984 81578 }
9985
9986 85478 void eTrap2::draw(BITMAP *dest)
9987 {
9988 85478 update_enemy_frame();
9989 85478 enemy::draw(dest);
9990 85478 }
9991
9992 531 int32_t eTrap2::takehit(weapon*,weapon*)
9993 {
9994 531 return 0;
9995 }
9996
9997 226 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9998 226 {
9999 //do not show "enemy appering" anim -DD
10000 226 clk=0;
10001 226 mainguy=false;
10002 226 clk2=-14;
10003 //Enemy Editor Size Tab
10004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10005 226 else hxofs = -2;
10006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10007 226 else hyofs = -2;
10008
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10009 226 else hit_width = 20;
10010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10011 226 else hit_height=20;
10012
10013
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10014
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10016
1/4
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10018 {
10019 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10020 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10021 }
10022
10023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10024 //nets+1640;
10025 226 }
10026
10027 79036 bool eRock::animate(int32_t index)
10028 {
10029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79036 times.
79036 if(switch_hooked) return enemy::animate(index);
10030
2/4
✓ Branch 0 taken 79036 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79036 times.
79036 if(fallclk||drownclk) return enemy::animate(index);
10031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79036 times.
79036 if(dying)
10032 return Dead(index);
10033
10034
2/2
✓ Branch 0 taken 73519 times.
✓ Branch 1 taken 5517 times.
79036 if(clk==0)
10035 {
10036 5517 removearmos(x,y,ffcactivated);
10037 5517 }
10038
10039
2/2
✓ Branch 0 taken 78591 times.
✓ Branch 1 taken 445 times.
79036 if(++clk2==0) // start it
10040 {
10041 445 x=zc_oldrand()&0xF0;
10042 445 y=0;
10043 445 clk3=0;
10044 445 clk2=zc_oldrand()&15;
10045 445 }
10046
10047
2/2
✓ Branch 0 taken 14660 times.
✓ Branch 1 taken 64376 times.
79036 if(clk2>16) // move it
10048 {
10049
2/2
✓ Branch 0 taken 62155 times.
✓ Branch 1 taken 2221 times.
64376 if(clk3<=0) // start bounce
10050 {
10051 2221 dir=zc_oldrand()&1;
10052
10053
2/2
✓ Branch 0 taken 1966 times.
✓ Branch 1 taken 255 times.
2221 if(x<32) dir=1;
10054
10055
2/2
✓ Branch 0 taken 2040 times.
✓ Branch 1 taken 181 times.
2221 if(x>208) dir=0;
10056 2221 }
10057
10058
2/2
✓ Branch 0 taken 62303 times.
✓ Branch 1 taken 2073 times.
64376 if(clk3<13+16)
10059 {
10060 62303 x += dir ? 1 : -1; //right, left
10061 62303 dummy_int[1]=dir;
10062
10063
2/2
✓ Branch 0 taken 4436 times.
✓ Branch 1 taken 57867 times.
62303 if(clk3<2)
10064 {
10065 4436 y-=2; //up
10066 4436 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10067 4436 }
10068
2/2
✓ Branch 0 taken 6614 times.
✓ Branch 1 taken 51253 times.
57867 else if(clk3<5)
10069 {
10070 6614 y--; //up
10071 6614 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10072 6614 }
10073
2/2
✓ Branch 0 taken 6569 times.
✓ Branch 1 taken 44684 times.
51253 else if(clk3<8)
10074 {
10075 6569 dummy_int[2]=(dummy_int[1]==1)?right:left;
10076 6569 }
10077
2/2
✓ Branch 0 taken 6518 times.
✓ Branch 1 taken 38166 times.
44684 else if(clk3<11)
10078 {
10079 6518 y++; //down
10080 6518 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10081 6518 }
10082 else
10083 {
10084 38166 y+=2; //down
10085 38166 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10086 }
10087
10088 62303 ++clk3;
10089 62303 }
10090
2/2
✓ Branch 0 taken 1793 times.
✓ Branch 1 taken 280 times.
2073 else if(y<176)
10091 1793 clk3=0; // next bounce
10092 else
10093 280 clk2 = -(zc_oldrand()&63); // back to top
10094 64376 }
10095
10096 79036 return enemy::animate(index);
10097 79036 }
10098
10099 21684 void eRock::drawshadow(BITMAP *dest, bool translucent)
10100 {
10101
2/2
✓ Branch 0 taken 2969 times.
✓ Branch 1 taken 18715 times.
21684 if(clk2>=0)
10102 {
10103 18715 int32_t tempy=yofs;
10104 18715 flip = 0;
10105 18715 int32_t fdiv = frate/4;
10106
1/2
✓ Branch 0 taken 18715 times.
✗ Branch 1 not taken.
18715 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
10107
1/2
✓ Branch 0 taken 18715 times.
✗ Branch 1 not taken.
18715 int32_t f2=get_qr(qr_NEWENEMYTILES)?
10108 18715 efrate:((clk>=(frate>>1))?1:0);
10109 18715 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10110
10111 18715 yofs+=8;
10112
6/6
✓ Branch 0 taken 8758 times.
✓ Branch 1 taken 9957 times.
✓ Branch 2 taken 16513 times.
✓ Branch 3 taken 2202 times.
✓ Branch 4 taken 8135 times.
✓ Branch 5 taken 8378 times.
18715 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18715 times.
18715 if(!shadow_overpit(this))
10114 18715 enemy::drawshadow(dest, translucent);
10115 18715 yofs=tempy;
10116 18715 }
10117 21684 }
10118
10119 79097 void eRock::draw(BITMAP *dest)
10120 {
10121
4/6
✓ Branch 0 taken 10969 times.
✓ Branch 1 taken 68128 times.
✓ Branch 2 taken 10969 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10969 times.
79097 if(clk2>=0 || fallclk||drownclk)
10122 {
10123 68128 int32_t tempdir=dir;
10124 68128 dir=dummy_int[2];
10125 68128 update_enemy_frame();
10126 68128 enemy::draw(dest);
10127 68128 dir=tempdir;
10128 68128 }
10129 79097 }
10130
10131 859 int32_t eRock::takehit(weapon*,weapon*)
10132 {
10133 859 return 0;
10134 }
10135
10136 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10137 30 {
10138 30 clk=0;
10139 30 mainguy=false;
10140 30 clk2=-14;
10141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10142 30 else hxofs= -10;
10143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10144 30 else hyofs=-10;
10145
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10146 30 else hit_width=36;
10147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10148 30 else hit_height=36;
10149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10150 30 else hzsz=16; //can't be jumped
10151
10152
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10153
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10155
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10157 {
10158 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10159 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10160 }
10161
10162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10163 //nets+1680;
10164 30 }
10165
10166 4440 bool eBoulder::animate(int32_t index)
10167 {
10168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
10169
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
10170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
10171 return Dead(index);
10172
10173
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
10174 {
10175 290 removearmos(x,y,ffcactivated);
10176 290 }
10177
10178 zfix *vert;
10179
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
10180
10181
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
10182 {
10183 32 x=zc_oldrand()&0xF0;
10184 32 y=-32;
10185 32 clk3=0;
10186 32 clk2=zc_oldrand()&15;
10187 32 }
10188
10189
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10190 {
10191
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10192 {
10193 131 dir=zc_oldrand()&1;
10194
10195
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10196
10197
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10198 131 }
10199
10200
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10201 {
10202 3487 x += dir ? 1 : -1; //right, left
10203 3487 dummy_int[1]=dir;
10204
10205
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10206 {
10207 261 y-=2; //up
10208 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10209 261 }
10210
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10211 {
10212 382 y--; //up
10213 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10214 382 }
10215
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10216 {
10217 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10218 376 }
10219
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10220 {
10221 367 y++; //down
10222 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10223 367 }
10224 else
10225 {
10226 2101 y+=2; //down
10227 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10228 }
10229
10230 3487 ++clk3;
10231 3487 }
10232
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10233 101 clk3=0; // next bounce
10234 else
10235 10 clk2 = -(zc_oldrand()&63); // back to top
10236 3598 }
10237
10238 4440 return enemy::animate(index);
10239 4440 }
10240
10241 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10242 {
10243
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10244 {
10245 3868 int32_t tempy=yofs;
10246 3868 flip = 0;
10247 3868 int32_t f2=((clk<<2)/frate)<<1;
10248 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10249
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10250
10251 3868 yofs+=8;
10252 3868 xofs-=8;
10253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10254 3868 enemy::drawshadow(dest, translucent);
10255 3868 xofs+=16;
10256 3868 ++shadowtile;
10257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10258 3868 enemy::drawshadow(dest, translucent);
10259 3868 yofs+=16;
10260 3868 shadowtile+=20;
10261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10262 3868 enemy::drawshadow(dest, translucent);
10263 3868 xofs-=16;
10264 3868 --shadowtile;
10265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10266 3868 enemy::drawshadow(dest, translucent);
10267 3868 xofs+=8;
10268 3868 yofs=tempy;
10269 3868 }
10270 4440 }
10271
10272 4440 void eBoulder::draw(BITMAP *dest)
10273 {
10274
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10275 {
10276 3868 int32_t tempdir=dir;
10277 3868 dir=dummy_int[2];
10278 3868 update_enemy_frame();
10279 3868 dir=tempdir;
10280 3868 xofs-=8;
10281 3868 yofs-=8;
10282 3868 drawblock(dest,15);
10283 3868 xofs+=8;
10284 3868 yofs+=8;
10285 // enemy::draw(dest);
10286 3868 }
10287 4440 }
10288
10289 int32_t eBoulder::takehit(weapon*,weapon*)
10290 {
10291 return 0;
10292 }
10293
10294 2257 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10295
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 1743 times.
2257 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10296 2257 {
10297 /* fixing
10298 hp=1;
10299 */
10300 2257 mainguy=false;
10301
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2250 times.
2257 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10302 2257 hclk=clk; // the "no fire" range
10303 2257 clk=0;
10304 2257 clk3=96;
10305 2257 timer=0;
10306
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2250 times.
2257 if(o_tile==0)
10307 {
10308 2250 superman=1;
10309 2250 hxofs=1000;
10310 2250 }
10311 2257 SIZEflags = d->SIZEflags;
10312
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10313 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10314 // al_trace("Enemy txsz:%i\n", txsz);
10315
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10316
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10317
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10318
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10319
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10320
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10321 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10322
1/4
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10324 {
10325 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10326 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10327 }
10328
10329
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10330 2257 }
10331
10332 1551984 bool eProjectile::animate(int32_t index)
10333 {
10334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1551984 times.
1551984 if(switch_hooked) return enemy::animate(index);
10335
2/4
✓ Branch 0 taken 1551984 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1551984 times.
1551984 if(fallclk||drownclk) return enemy::animate(index);
10336
2/2
✓ Branch 0 taken 1544504 times.
✓ Branch 1 taken 7480 times.
1551984 if(clk==0)
10337 {
10338 7480 removearmos(x,y,ffcactivated);
10339 7480 }
10340
10341 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10342 1551984 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10343
10344
4/4
✓ Branch 0 taken 507924 times.
✓ Branch 1 taken 1044060 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 229115 times.
1551984 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10345 {
10346 229115 dir=down;
10347 229115 }
10348
4/4
✓ Branch 0 taken 850200 times.
✓ Branch 1 taken 472669 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 571391 times.
1322869 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10349 {
10350 571391 dir=right;
10351 571391 }
10352
4/4
✓ Branch 0 taken 519744 times.
✓ Branch 1 taken 231734 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 240935 times.
751478 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10353 {
10354 240935 dir=up;
10355 240935 }
10356 else
10357 {
10358 510543 dir=left;
10359 }
10360
10361
3/4
✓ Branch 0 taken 1551984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 812552 times.
✓ Branch 3 taken 739432 times.
1551984 if(!stunclk && ++clk3>80)
10362 {
10363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 739432 times.
739432 if(dmisc1==9) // Breath type
10364 {
10365 if(timer==0)
10366 {
10367 unsigned r=zc_oldrand();
10368
10369 if(!(r&63))
10370 {
10371 timer=zc_oldrand()%50+50;
10372 }
10373 }
10374
10375 if(timer>0)
10376 {
10377 if(timer%4==0)
10378 {
10379 FireBreath(false);
10380 }
10381
10382 if(--timer==0)
10383 {
10384 clk3=0;
10385 }
10386 }
10387 }
10388
10389 else // Not breath type
10390 {
10391 739432 unsigned r=zc_oldrand();
10392
10393
4/4
✓ Branch 0 taken 11616 times.
✓ Branch 1 taken 727816 times.
✓ Branch 2 taken 839 times.
✓ Branch 3 taken 10777 times.
739432 if(!(r&63) && !HeroInRange(minRange))
10394 {
10395 10777 FireWeapon();
10396
10397
3/4
✓ Branch 0 taken 8406 times.
✓ Branch 1 taken 2371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
10838 if(get_qr(qr_BROKENSTATUES)==0 &&
10398
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 8345 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
8406 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10399 {
10400
2/2
✓ Branch 0 taken 7924 times.
✓ Branch 1 taken 482 times.
8406 if(!((r>>7)&15))
10401 {
10402 482 x-=4;
10403 482 FireWeapon();
10404 482 x+=4;
10405 482 }
10406 8406 }
10407
10408 10777 clk3=0;
10409 10777 }
10410 }
10411 739432 }
10412
10413 1551984 return enemy::animate(index);
10414 1551984 }
10415
10416 1557825 void eProjectile::draw(BITMAP *dest)
10417 {
10418 1557825 update_enemy_frame();
10419 1557825 enemy::draw(dest);
10420 1557825 }
10421
10422 90 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10423 90 {
10424 90 hxofs=1000;
10425 90 }
10426
10427 12175 void eTrigger::draw(BITMAP *dest)
10428 {
10429 12175 update_enemy_frame();
10430 12175 enemy::draw(dest);
10431 12175 }
10432
10433 void eTrigger::death_sfx()
10434 {
10435 //silent death
10436 }
10437
10438 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10439 {
10440 o_tile+=wpnsbuf[iwNPCs].tile;
10441 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10442 SIZEflags = d->SIZEflags;
10443 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10444 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10445 // al_trace("Enemy txsz:%i\n", txsz);
10446 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10447 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10448 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10449 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10450 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10451 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10452 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10453 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10454 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10455 {
10456 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10457 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10458 }
10459
10460 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10461 }
10462
10463 bool eNPC::animate(int32_t index)
10464 {
10465 if(switch_hooked) return enemy::animate(index);
10466 if(dying)
10467 return Dead(index);
10468
10469 if(clk==0)
10470 {
10471 removearmos(x,y,ffcactivated);
10472 }
10473
10474 switch(dmisc2)
10475 {
10476 case 0:
10477 {
10478 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10479 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10480
10481 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10482 {
10483 dir=down;
10484 }
10485
10486 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10487 {
10488 dir=right;
10489 }
10490 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10491 {
10492 dir=up;
10493 }
10494 else
10495 {
10496 dir=left;
10497 }
10498 }
10499 break;
10500
10501 case 1:
10502 halting_walk(rate, homing, 0, hrate, 48);
10503
10504 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10505 {
10506 newdir(rate, homing, 0);
10507 clk2=48;
10508 ++misc;
10509 }
10510
10511 if(clk2==0)
10512 misc=0;
10513
10514 break;
10515 }
10516
10517 return enemy::animate(index);
10518 }
10519
10520 void eNPC::draw(BITMAP *dest)
10521 {
10522 update_enemy_frame();
10523 enemy::draw(dest);
10524 }
10525
10526 int32_t eNPC::takehit(weapon*,weapon*)
10527 {
10528 return 0;
10529 }
10530
10531 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10532 94 {
10533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10534 {
10535 94 o_tile=clk;
10536 94 cs=id>>12;
10537 94 }
10538
10539 94 id=id&0xFFF;
10540 94 clk=0;
10541
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10542 94 mainguy=false;
10543 94 SIZEflags = d->SIZEflags;
10544
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10545 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10546 // al_trace("Enemy txsz:%i\n", txsz);
10547
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10549
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10550
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10551
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10552
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10553 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10554
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10556 {
10557 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10558 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10559 }
10560
10561
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10562 94 }
10563
10564 81 void eSpinTile::facehero()
10565 {
10566
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10567 {
10568
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10569 1 dir = up;
10570 else
10571 dir = down;
10572 1 }
10573 else
10574 {
10575 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10576 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10577
10578
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10579 {
10580 12 dir=l_down;
10581 12 }
10582
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10583 {
10584 1 dir=down;
10585 1 }
10586
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10587 {
10588 12 dir=r_down;
10589 12 }
10590
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10591 {
10592 6 dir=right;
10593 6 }
10594
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10595 {
10596 17 dir=r_up;
10597 17 }
10598
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10599 {
10600 8 dir=up;
10601 8 }
10602
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10603 {
10604 6 dir=l_up;
10605 6 }
10606 else
10607 {
10608 18 dir=left;
10609 }
10610 }
10611 81 }
10612
10613
10614 15539 bool eSpinTile::animate(int32_t index)
10615 {
10616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10617
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10618
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10619 {
10620 1152 return Dead(index);
10621 }
10622
10623
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10624 {
10625 1241 removearmos(x,y,ffcactivated);
10626 1241 }
10627
10628 14387 ++misc;
10629
10630
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10631 {
10632 81 facehero();
10633 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10634 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10635 81 angular=true;
10636 81 angle=ddir;
10637 81 step=zslongToFix(dstep*100);
10638 81 }
10639
10640
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10641 52 kickbucket();
10642
10643 14387 sprite::move(step);
10644 14387 return enemy::animate(index);
10645 15539 }
10646
10647 15457 void eSpinTile::draw(BITMAP *dest)
10648 {
10649 15457 update_enemy_frame();
10650 15457 y-=(misc>>4);
10651 15457 yofs+=2;
10652 15457 enemy::draw(dest);
10653 15457 yofs-=2;
10654 15457 y+=(misc>>4);
10655 15457 }
10656
10657 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10658 {
10659 15457 flip = 0;
10660 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10661 15457 yofs+=4;
10662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10663 15457 enemy::drawshadow(dest, translucent);
10664 15457 yofs-=4;
10665 15457 }
10666
10667 1605 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10668 1605 {
10669 //these are here to bypass compiler warnings about unused arguments
10670 1605 Clk=Clk;
10671 1605 mainguy=false;
10672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10673 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
10674 {
10675 clk=1;
10676 }*/
10677 //nets+880;
10678 1605 SIZEflags = d->SIZEflags;
10679
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10680 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10681 // al_trace("Enemy txsz:%i\n", txsz);
10682
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10683
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10684
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10685
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10686
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10687
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10688 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10689
1/4
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10691 {
10692 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10693 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10694 }
10695
10696
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10697 1605 }
10698
10699 392118 void eZora::facehero()
10700 {
10701
2/2
✓ Branch 0 taken 6564 times.
✓ Branch 1 taken 385554 times.
392118 if(Hero.x-x==0)
10702 {
10703 6564 dir=(Hero.y+8<y)?up:down;
10704 6564 }
10705 else
10706 {
10707 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10708 385554 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10709
10710
4/4
✓ Branch 0 taken 80572 times.
✓ Branch 1 taken 304982 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 49955 times.
385554 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10711 {
10712 49955 dir=l_down;
10713 49955 }
10714
4/4
✓ Branch 0 taken 57428 times.
✓ Branch 1 taken 278171 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 26811 times.
335599 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10715 {
10716 26811 dir=down;
10717 26811 }
10718
4/4
✓ Branch 0 taken 77619 times.
✓ Branch 1 taken 231169 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 47002 times.
308788 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10719 {
10720 47002 dir=r_down;
10721 47002 }
10722
4/4
✓ Branch 0 taken 102786 times.
✓ Branch 1 taken 159000 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 72169 times.
261786 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10723 {
10724 72169 dir=right;
10725 72169 }
10726
4/4
✓ Branch 0 taken 83714 times.
✓ Branch 1 taken 105903 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 53097 times.
189617 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10727 {
10728 53097 dir=r_up;
10729 53097 }
10730
4/4
✓ Branch 0 taken 54641 times.
✓ Branch 1 taken 81879 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 24024 times.
136520 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10731 {
10732 24024 dir=up;
10733 24024 }
10734
4/4
✓ Branch 0 taken 76377 times.
✓ Branch 1 taken 36119 times.
✓ Branch 2 taken 45760 times.
✓ Branch 3 taken 30617 times.
112496 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10735 {
10736 45760 dir=l_up;
10737 45760 }
10738 else
10739 {
10740 66736 dir=left;
10741 }
10742 }
10743 392118 }
10744
10745 554408 bool eZora::animate(int32_t index)
10746 {
10747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 554408 times.
554408 if(switch_hooked) return enemy::animate(index);
10748
2/2
✓ Branch 0 taken 1868 times.
✓ Branch 1 taken 552540 times.
554408 if(dying)
10749 1868 return Dead(index);
10750
10751
2/2
✓ Branch 0 taken 548931 times.
✓ Branch 1 taken 3609 times.
552540 if(clk==0)
10752 {
10753 3609 removearmos(x,y,ffcactivated);
10754 3609 }
10755
10756
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 552509 times.
552540 if(watch)
10757 {
10758 31 ++clock_zoras[id];
10759 31 return true;
10760 }
10761
10762
2/2
✓ Branch 0 taken 160391 times.
✓ Branch 1 taken 392118 times.
552509 if(get_qr(qr_NEWENEMYTILES))
10763 {
10764 392118 facehero();
10765 392118 }
10766
10767
6/6
✓ Branch 0 taken 3333 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 2684 times.
✓ Branch 3 taken 537009 times.
✓ Branch 4 taken 4269 times.
✓ Branch 5 taken 2014 times.
552509 switch(clk)
10768 {
10769 case 0: // reposition him
10770 {
10771 4269 int32_t t=0;
10772 4269 int32_t pos2=zc_oldrand()%160 + 16;
10773 4269 bool placed=false;
10774
10775
4/4
✓ Branch 0 taken 4246 times.
✓ Branch 1 taken 20492 times.
✓ Branch 2 taken 12637 times.
✓ Branch 3 taken 3609 times.
24738 while(!placed && t<160)
10776 {
10777 12637 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10778
5/6
✓ Branch 0 taken 4326 times.
✓ Branch 1 taken 8311 times.
✓ Branch 2 taken 4326 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✓ Branch 5 taken 3586 times.
16553 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4326 times.
4326 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10780
3/4
✓ Branch 0 taken 4326 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3916 times.
✓ Branch 3 taken 3916 times.
4326 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10781 {
10782 3586 x=(pos2&15)<<4;
10783 3586 y=pos2&0xF0;
10784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3586 times.
3586 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10785 3586 hxofs=1000; // avoid hit detection
10786 3586 stunclk=0;
10787 3586 placed=true;
10788 3586 }
10789
10790 20469 pos2+=19;
10791
10792
2/2
✓ Branch 0 taken 18055 times.
✓ Branch 1 taken 2414 times.
20469 if(pos2>=176)
10793 2414 pos2-=160;
10794
10795 20469 ++t;
10796 }
10797
10798
3/4
✓ Branch 0 taken 3586 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3586 times.
3609 if(!placed || whistleclk>=88) // can't place him, he's gone
10799 23 return true;
10800
10801 }
10802 3586 break;
10803
10804 case 35:
10805
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 965 times.
3333 if(!get_qr(qr_NEWENEMYTILES))
10806 {
10807 965 dir=(Hero.y+8<y)?up:down;
10808 965 }
10809
10810 3333 hxofs=0;
10811 3333 break;
10812
10813 case 35+19:
10814 3200 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10815 3200 sfx(wpnsfx(wpn),pan(int32_t(x)));
10816 3200 break;
10817
10818 case 35+66:
10819 2684 hxofs=1000;
10820 2684 break;
10821
10822 case 198:
10823 2014 clk=-1;
10824 2014 break;
10825 }
10826
10827 551826 return enemy::animate(index);
10828 553748 }
10829
10830 554283 void eZora::draw(BITMAP *dest)
10831 {
10832
2/2
✓ Branch 0 taken 10764 times.
✓ Branch 1 taken 543519 times.
554283 if(clk<3)
10833 10764 return;
10834
10835 543519 update_enemy_frame();
10836 543519 enemy::draw(dest);
10837 554283 }
10838
10839 bool eZora::isSubmerged() const
10840 {
10841 return ( clk < 3 );
10842 }
10843
10844
3/6
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26760 times.
✗ Branch 5 not taken.
53520 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10845 26760 {
10846 26760 multishot= timer = fired = dashing = 0;
10847 26760 hashero = false;
10848 26760 dummy_bool[0]=false;
10849 26760 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10850
5/6
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 26613 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✓ Branch 5 taken 71 times.
26760 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10851 {
10852
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 step=zslongToFix(dmisc10*100);
10853
10854
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 64 times.
76 if(anim==aARMOS4) o_tile+=20;
10855 76 }
10856
10857
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 26613 times.
26760 if(flags & guy_fadeflicker)
10858 {
10859 147 clk=0;
10860 147 superman = 1;
10861 147 fading=fade_flicker;
10862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10863 147 dir=down;
10864
10865
4/6
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 80 times.
147 if(!canmove(down,(zfix)8,spw_none,false))
10866
3/6
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✗ Branch 5 not taken.
67 clk3=int32_t(13.0/step);
10867 147 }
10868
2/2
✓ Branch 0 taken 26612 times.
✓ Branch 1 taken 1 times.
26613 else if(flags & guy_fadeinstant)
10869 {
10870 1 clk=0;
10871 1 }
10872
10873
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 shadowdistance = 0;
10874 26760 clk4 = clk5 = 0;
10875 //nets+2380;
10876 26760 SIZEflags = d->SIZEflags;
10877
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10878 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10879 // al_trace("Enemy txsz:%i\n", txsz);
10880
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10881
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10882
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10883
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10884
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10885
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10886 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10887
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10889 {
10890 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10891 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10892 }
10893
10894
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10895 26760 }
10896
10897 9630028 bool eStalfos::animate(int32_t index)
10898 {
10899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9630028 times.
9630028 if(switch_hooked) return enemy::animate(index);
10900
3/4
✓ Branch 0 taken 9629886 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9629886 times.
9630028 if(fallclk||drownclk)
10901 {
10902 142 return enemy::animate(index);
10903 }
10904
2/2
✓ Branch 0 taken 207899 times.
✓ Branch 1 taken 9421987 times.
9629886 if(dying)
10905 {
10906
2/2
✓ Branch 0 taken 207868 times.
✓ Branch 1 taken 31 times.
207899 if(hashero)
10907 {
10908 31 Hero.setEaten(0);
10909 31 hashero=false;
10910 31 }
10911
10912
10/14
✓ Branch 0 taken 20374 times.
✓ Branch 1 taken 187525 times.
✓ Branch 2 taken 1140 times.
✓ Branch 3 taken 19234 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 1091 times.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 49 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 49 times.
207899 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10913 {
10914 49 hp=-1000;
10915
5/10
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
49 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10916 49 Ewpns.add(ew);
10917 49 ew->fakez = fakez;
10918
10919
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
49 if(wpn==ewSBomb || wpn==ewBomb)
10920 {
10921 49 ew->step=0;
10922 49 ew->id=wpn;
10923 49 ew->misc=50;
10924 49 ew->clk=48;
10925 49 }
10926
10927 49 fired=true;
10928 49 }
10929
6/6
✓ Branch 0 taken 95092 times.
✓ Branch 1 taken 112758 times.
✓ Branch 2 taken 77556 times.
✓ Branch 3 taken 17536 times.
✓ Branch 4 taken 77538 times.
✓ Branch 5 taken 18 times.
207850 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10930 {
10931
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10932 {
10933 1 int32_t wpn2 = wpn+dmisc3;
10934
10935
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10936 {
10937 wpn2=wpn;
10938 }
10939
10940 1 dummy_bool[0]=true;
10941 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10942 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10943 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10944 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10945 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10946 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10947 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10948 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10949 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10950 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10951 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10952 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10953 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10954 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10955 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10956 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10957 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10958 1 }
10959 18 }
10960
10961 207899 KillWeapon();
10962 207899 return Dead(index);
10963 }
10964 //vire split
10965 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10966 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10967
13/14
✓ Branch 0 taken 11844 times.
✓ Branch 1 taken 9410143 times.
✓ Branch 2 taken 11844 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 11695 times.
✓ Branch 6 taken 819531 times.
✓ Branch 7 taken 8602307 times.
✓ Branch 8 taken 818273 times.
✓ Branch 9 taken 1258 times.
✓ Branch 10 taken 4401 times.
✓ Branch 11 taken 813872 times.
✓ Branch 12 taken 803 times.
✓ Branch 13 taken 3598 times.
9421987 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10968 {
10969 952 stop_bgsfx(index);
10970 952 int32_t kids = guys.Count();
10971 952 int32_t id2=dmisc3;
10972
2/2
✓ Branch 0 taken 1890 times.
✓ Branch 1 taken 952 times.
2842 for(int32_t i=0; i < dmisc4; i++)
10973 {
10974 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10975
4/6
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 1334 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1334 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1890 times.
1890 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10976 1890 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10977 1890 }
10978
10979
1/2
✓ Branch 0 taken 952 times.
✗ Branch 1 not taken.
952 if(itemguy) // Hand down the carried item
10980 {
10981 guycarryingitem = guys.Count()-1;
10982 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10983 itemguy = false;
10984 }
10985
10986
1/2
✓ Branch 0 taken 952 times.
✗ Branch 1 not taken.
952 if(hashero)
10987 {
10988 Hero.setEaten(0);
10989 hashero=false;
10990 }
10991
10992
4/4
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 803 times.
✓ Branch 3 taken 135 times.
952 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10993 135 sfx(deadsfx,pan(int32_t(x)));
10994
10995 952 return true;
10996 }
10997 /*
10998 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
10999 {
11000 stop_bgsfx(index);
11001 int32_t kids = guys.Count();
11002 int32_t id2=dmisc3;
11003
11004 for(int32_t i=0; i < dmisc4; i++)
11005 {
11006 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
11007 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
11008 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11009 }
11010
11011 if(itemguy) // Hand down the carried item
11012 {
11013 guycarryingitem = guys.Count()-1;
11014 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11015 itemguy = false;
11016 }
11017
11018 if(hashero)
11019 {
11020 Hero.setEaten(0);
11021 hashero=false;
11022 }
11023
11024 return true;
11025 }
11026 */
11027
2/2
✓ Branch 0 taken 12521 times.
✓ Branch 1 taken 9408514 times.
9421035 if(fading)
11028 {
11029
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 12312 times.
12521 if(++clk4 > 60)
11030 {
11031 209 clk4=0;
11032 209 superman=0;
11033 209 fading=0;
11034
11035
4/6
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
209 if(flags2&cmbflag_armos && z==0 && fakez == 0)
11036 {
11037 //if a custom size (not 16px by 16px)
11038
11039 //if a custom size (not 16px by 16px)
11040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if (ffcactivated)
11041 removearmosffc(ffcactivated-1);
11042 else
11043 {
11044
4/8
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 146 times.
146 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11045 {
11046 //zprint("spawn big enemy from armos\n");
11047 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11048 for(int32_t dx = 0; dx < tysz; dx ++)
11049 {
11050 for(int32_t dy = 0; dy < tysz; dy++)
11051 {
11052 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
11053 did_armos = false;
11054 }
11055 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
11056 did_armos = false;
11057 }
11058 for(int32_t dy = 0; dy < tysz; dy ++)
11059 {
11060 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
11061 did_armos = false;
11062 }
11063 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
11064 }
11065 146 else removearmos(x,y);
11066 }
11067 /*
11068 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11069 {
11070 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11071 for(int32_t dx = 0; dx < hxsz; dx += 16)
11072 {
11073 for(int32_t dy = 0; dy < hysz; dy += 16)
11074 {
11075 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
11076 did_armos = false;
11077 }
11078 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11079 did_armos = false;
11080 }
11081 for(int32_t dy = 0; dy < hysz; dy += 16)
11082 {
11083 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
11084 did_armos = false;
11085 }
11086 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11087 }
11088 else removearmos(x,y,ffcactivated);
11089 */
11090
11091 146 }
11092
11093 209 clk2=0;
11094
11095 209 newdir();
11096 209 }
11097 12312 else return enemy::animate(index);
11098 209 }
11099
6/8
✓ Branch 0 taken 33168 times.
✓ Branch 1 taken 9375346 times.
✓ Branch 2 taken 33168 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33168 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31059 times.
✓ Branch 7 taken 2109 times.
9408514 else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0)
11100 2109 removearmos(x,y,ffcactivated);
11101
11102
11103
2/2
✓ Branch 0 taken 2540 times.
✓ Branch 1 taken 9406183 times.
9408723 if(hashero)
11104 {
11105 2540 Hero.setX(x);
11106 2540 Hero.setY(y);
11107 2540 ++clk2;
11108
11109
4/4
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 2489 times.
✓ Branch 3 taken 51 times.
2540 if(clk2==(dmisc8==0 ? 95 : dmisc8))
11110 {
11111
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
51 switch(dmisc7)
11112 {
11113 case e7tEATITEMS:
11114 {
11115
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<MAXITEMS; i++)
11116 {
11117
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 1 times.
256 if(itemsbuf[i].flags&ITEM_EDIBLE)
11118 1 game->set_item(i, false);
11119 256 }
11120
11121 1 break;
11122 }
11123
11124 case e7tEATMAGIC:
11125 game->change_dmagic(-1*game->get_magicdrainrate());
11126 break;
11127
11128 case e7tEATRUPEES:
11129 game->change_drupy(-1);
11130 break;
11131 }
11132
11133 51 clk2=0;
11134 51 }
11135
11136
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 2335 times.
2540 if((clk&0x18)==8) // stop its animation on the middle frame
11137 2335 --clk;
11138 2540 }
11139
4/4
✓ Branch 0 taken 700114 times.
✓ Branch 1 taken 8706069 times.
✓ Branch 2 taken 408221 times.
✓ Branch 3 taken 291893 times.
9406183 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
11140 {
11141 // Movement engine
11142
4/6
✓ Branch 0 taken 504520 times.
✓ Branch 1 taken 8609770 times.
✓ Branch 2 taken 2332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8607438 times.
✗ Branch 5 not taken.
9114290 if(clk>=0) switch(id>>12)
11143 {
11144 case 0: // Normal movement
11145
11146 /*
11147 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
11148 {
11149 // Overloading clk4 (Tribble clock) here...
11150 step=17/100.0;
11151 if(clk4<32) misc=1;
11152 else if(clk4<48) misc=2;
11153 else if(clk4<300) { misc=3; step = dstep/100.0; }
11154 else if(clk4<316) misc=2;
11155 else if(clk4<412) misc=1;
11156 else if(clk4<540) { misc=0; step=0; }
11157 else clk4=0;
11158 if(clk4==48) clk=0;
11159 hxofs=(misc>=2)?0:1000;
11160 if (dmisc9==e9tLEEVER)
11161 variable_walk(rate, homing, 0);
11162 else
11163 variable_walk_8(rate, homing, 4, 0);
11164 break;
11165 }
11166 */
11167
4/4
✓ Branch 0 taken 8408380 times.
✓ Branch 1 taken 199058 times.
✓ Branch 2 taken 273002 times.
✓ Branch 3 taken 8135378 times.
8607438 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
11168 {
11169 472060 vire_hop();
11170 472060 break;
11171 }
11172
2/2
✓ Branch 0 taken 649572 times.
✓ Branch 1 taken 7485806 times.
8135378 else if(dmisc9==e9tROPE) //Rope charge
11173 {
11174
9/10
✓ Branch 0 taken 632150 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 89355 times.
✓ Branch 3 taken 542795 times.
✓ Branch 4 taken 80424 times.
✓ Branch 5 taken 8931 times.
✓ Branch 6 taken 79638 times.
✓ Branch 7 taken 786 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79638 times.
649572 if(!fired && dashing && !stunclk && !watch && !frozenclock)
11175 {
11176
5/6
✓ Branch 0 taken 2372 times.
✓ Branch 1 taken 77266 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2357 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
79638 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
11177 {
11178
11179
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
11180 {
11181 14 hp=-1000;
11182
11183
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11184 {
11185
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
11186 14 Ewpns.add(ew);
11187 14 ew->fakez = fakez;
11188
11189
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
11190 {
11191 14 ew->step=0;
11192 14 ew->id=wpn+dmisc3;
11193 14 ew->misc=50;
11194 14 ew->clk=48;
11195 14 }
11196
11197 14 fired=true;
11198 14 }
11199 else
11200 {
11201 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
11202 Ewpns.add(ew);
11203 ew->fakez = fakez;
11204
11205 if(wpn==ewSBomb || wpn==ewBomb)
11206 {
11207 ew->step=0;
11208 ew->id=wpn;
11209 ew->misc=50;
11210 ew->clk=48;
11211 }
11212
11213 fired=true;
11214 }
11215 14 }
11216
11217 else
11218 {
11219 1 hp=-1000;
11220
11221 int32_t wpn2;
11222
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11223 1 wpn2=wpn;
11224 else
11225 wpn2=wpn;
11226
11227
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
11228 1 Ewpns.add(ew);
11229 1 ew->fakez = fakez;
11230
11231
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(wpn2==ewSBomb || wpn2==ewBomb)
11232 {
11233 1 ew->step=0;
11234 1 ew->id=wpn2;
11235 1 ew->misc=50;
11236 1 ew->clk=48;
11237 1 }
11238
11239 1 fired=true;
11240 }
11241 15 }
11242 79638 }
11243
11244 649572 charge_attack();
11245 649572 break;
11246 }
11247 /*
11248 * Boomerang-throwers have a halt count of 1
11249 * Zols have a halt count of (zc_oldrand()&7)<<4
11250 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
11251 * Everything else has 48
11252 */
11253 else
11254 {
11255
2/2
✓ Branch 0 taken 378407 times.
✓ Branch 1 taken 7107399 times.
7485806 if(wpn==ewBrang) // Goriya
11256 {
11257 378407 halting_walk(rate,homing,0,hrate, 1);
11258 378407 }
11259
4/4
✓ Branch 0 taken 7074085 times.
✓ Branch 1 taken 33314 times.
✓ Branch 2 taken 2912329 times.
✓ Branch 3 taken 4161756 times.
7107399 else if(dmisc9==e9tNORMAL && wpn==0)
11260 {
11261
2/2
✓ Branch 0 taken 574887 times.
✓ Branch 1 taken 3586869 times.
4161756 if(dmisc2==e2tSPLITHIT) // Zol
11262 {
11263 574887 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
11264 574887 }
11265
4/4
✓ Branch 0 taken 1147347 times.
✓ Branch 1 taken 2439522 times.
✓ Branch 2 taken 1047903 times.
✓ Branch 3 taken 99444 times.
3586869 else if(frate<=8 && starting_hp==1) // Gel
11266 {
11267 99444 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
11268 99444 }
11269 else // Other
11270 {
11271 3487425 halting_walk(rate,homing,0,hrate, 48);
11272 }
11273 4161756 }
11274 else // Other
11275 {
11276 2945643 halting_walk(rate,homing,0,hrate, 48);
11277 }
11278 }
11279
11280 //if not in midair, and Hero's swinging sword is nearby, jump.
11281 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
11282 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
11283 {
11284 facehero(false);
11285 sclk=16+((dir^1)<<8);
11286 fall=-FEATHERJUMP;
11287 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
11288 }*/
11289 7485806 break;
11290
11291 // Following cases are for just after creation-by-splitting.
11292 case 1:
11293
2/2
✓ Branch 0 taken 1752 times.
✓ Branch 1 taken 580 times.
2332 if(misc==1)
11294 {
11295 580 dir=up;
11296 580 step=8;
11297 580 }
11298
11299
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 1773 times.
2332 if(misc<=2)
11300 {
11301 1773 move(step);
11302
11303
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 343 times.
1773 if(!canmove(dir,(zfix)0,0,false))
11304 343 dir=down;
11305 1773 }
11306
11307
2/2
✓ Branch 0 taken 1773 times.
✓ Branch 1 taken 559 times.
2332 if(misc==3)
11308 {
11309
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 350 times.
559 if(canmove(right,(zfix)16,0,false))
11310 350 x+=16;
11311 559 }
11312
11313 2332 ++misc;
11314 2332 break;
11315
11316 case 2:
11317 if(misc==1)
11318 {
11319 dir=down;
11320 step=8;
11321 }
11322
11323 if(misc<=2)
11324 {
11325 move(step);
11326 /*
11327 if(!canmove(dir,(zfix)0,0,false))
11328 dir=up;
11329 */
11330 }
11331
11332 if(misc==3)
11333 {
11334 if(canmove(left,(zfix)16,0,false))
11335 x-=16;
11336 }
11337
11338 ++misc;
11339 break;
11340
11341 default:
11342 if(misc==1)
11343 {
11344 dir=(zc_oldrand()%4);
11345 step=8;
11346 }
11347
11348 if(misc<=2)
11349 {
11350 move(step);
11351
11352 if(!canmove(dir,(zfix)0,0,false))
11353 dir=dir^1;
11354 }
11355
11356 if(misc==3)
11357 {
11358 if(dir >= left && canmove(dir,(zfix)16,0,false))
11359 x+=(dir==left ? -16 : 16);
11360 }
11361
11362 ++misc;
11363 break;
11364 8609770 }
11365
11366
4/4
✓ Branch 0 taken 16816 times.
✓ Branch 1 taken 9097474 times.
✓ Branch 2 taken 16257 times.
✓ Branch 3 taken 559 times.
9114290 if(id>>12 && misc>=4) //recently spawned by a split enemy
11367 {
11368 559 id&=0xFFF;
11369 559 step = zslongToFix(dstep*100);
11370
11371
1/2
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
559 if(x<32) x=32;
11372
11373
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 13 times.
559 if(x>208) x=208;
11374
11375
2/2
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 18 times.
559 if(y<32) y=32;
11376
11377
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 5 times.
559 if(y>128) y=128;
11378
11379 559 misc=3;
11380 559 }
11381 9114290 }
11382 else
11383 {
11384 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11385
1/2
✓ Branch 0 taken 291893 times.
✗ Branch 1 not taken.
291893 if(clk2>2) clk2--;
11386 }
11387
11388 // Fire Zol
11389
7/8
✓ Branch 0 taken 3944791 times.
✓ Branch 1 taken 5463932 times.
✓ Branch 2 taken 6634 times.
✓ Branch 3 taken 3938157 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 6587 times.
✓ Branch 6 taken 47 times.
✗ Branch 7 not taken.
9408723 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11390 {
11391 47 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11392 47 sfx(wpnsfx(wpn),pan(int32_t(x)));
11393
11394 47 int32_t i=Ewpns.Count()-1;
11395 47 weapon *ew = (weapon*)(Ewpns.spr(i));
11396
11397
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11398 {
11399 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11400 if ( ew->do_animation ) ew->tile+=ew->aframe;
11401 }
11402 47 }
11403 // Goriya
11404
14/16
✓ Branch 0 taken 700114 times.
✓ Branch 1 taken 8708562 times.
✓ Branch 2 taken 318261 times.
✓ Branch 3 taken 381853 times.
✓ Branch 4 taken 310952 times.
✓ Branch 5 taken 7309 times.
✓ Branch 6 taken 286403 times.
✓ Branch 7 taken 24549 times.
✓ Branch 8 taken 286403 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 283662 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 283662 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 279458 times.
✓ Branch 15 taken 4204 times.
9408676 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11405 {
11406 4204 misc=index+100;
11407
7/14
✓ Branch 0 taken 4204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4204 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4204 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4204 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4204 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4204 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4204 times.
✗ Branch 13 not taken.
4204 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11408 4204 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11409
11410
2/2
✓ Branch 0 taken 4049 times.
✓ Branch 1 taken 155 times.
4204 if(dmisc1==2)
11411 {
11412 155 int32_t ndir=dir;
11413
11414
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 151 times.
155 if(Hero.x-x==0)
11415 {
11416 4 ndir=(Hero.y+8<y)?up:down;
11417 4 }
11418 else //turn to face Hero
11419 {
11420 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11421 151 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11422
11423
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 9 times.
151 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11424 {
11425 9 ndir=down;
11426 9 }
11427
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 41 times.
142 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11428 {
11429 41 ndir=right;
11430 41 }
11431
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 33 times.
101 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11432 {
11433 33 ndir=up;
11434 33 }
11435 else
11436 {
11437 68 ndir=left;
11438 }
11439 }
11440
11441 155 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11442
11443
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 153 times.
155 if(canmove(ndir,false))
11444 {
11445 153 dir=ndir;
11446 153 }
11447 155 }
11448 4204 }
11449
15/16
✓ Branch 0 taken 9367609 times.
✓ Branch 1 taken 36863 times.
✓ Branch 2 taken 121574 times.
✓ Branch 3 taken 9282898 times.
✓ Branch 4 taken 106507 times.
✓ Branch 5 taken 15067 times.
✓ Branch 6 taken 91800 times.
✓ Branch 7 taken 14707 times.
✓ Branch 8 taken 91114 times.
✓ Branch 9 taken 686 times.
✓ Branch 10 taken 82969 times.
✓ Branch 11 taken 8145 times.
✓ Branch 12 taken 82969 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 82025 times.
9404472 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11450
3/3
✓ Branch 0 taken 16959 times.
✓ Branch 1 taken 64165 times.
✓ Branch 2 taken 901 times.
82025 switch(dmisc1)
11451 {
11452 case e1tCONSTANT: //Deathnut
11453 {
11454 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11455
2/2
✓ Branch 0 taken 62822 times.
✓ Branch 1 taken 1343 times.
64165 if(clk5>64)
11456 {
11457 1343 clk5=0;
11458 1343 fired=false;
11459 1343 }
11460
11461 64165 clk5+=(zc_oldrand()&3);
11462
11463
4/4
✓ Branch 0 taken 39489 times.
✓ Branch 1 taken 24676 times.
✓ Branch 2 taken 13354 times.
✓ Branch 3 taken 26135 times.
64165 if((clk5>24)&&(clk5<52))
11464 {
11465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26135 times.
26135 if ( do_animation )tile+=20; //firing
11466
11467
4/4
✓ Branch 0 taken 14252 times.
✓ Branch 1 taken 11883 times.
✓ Branch 2 taken 12803 times.
✓ Branch 3 taken 1449 times.
26135 if(!fired&&(clk5>=38))
11468 {
11469
5/10
✓ Branch 0 taken 1449 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1449 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1449 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1449 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1449 times.
✗ Branch 9 not taken.
1449 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11470 1449 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11471 1449 sfx(wpnsfx(wpn),pan(int32_t(x)));
11472 1449 fired=true;
11473 1449 }
11474 26135 }
11475
11476 64165 break;
11477 }
11478
11479 case e1tFIREOCTO: //Fire Octo
11480 901 timer=zc_oldrand()%50+50;
11481 901 break;
11482
11483 default:
11484 16959 FireWeapon();
11485 16959 break;
11486 82025 }
11487
11488 /* Fire again if:
11489 * - clk2 about to run out
11490 * - not already double-firing (dmisc1 is 1)
11491 * - not carrying Hero
11492 * - one in 0xF chance
11493 */
11494
8/10
✓ Branch 0 taken 352788 times.
✓ Branch 1 taken 9055935 times.
✓ Branch 2 taken 3024 times.
✓ Branch 3 taken 349764 times.
✓ Branch 4 taken 3024 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3024 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2830 times.
✓ Branch 9 taken 194 times.
9408723 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11495 {
11496 #if 1
11497 194 newdir(rate, homing, grumble);
11498 #else
11499 dir^=2;
11500 #endif
11501 194 clk2=28;
11502 194 ++multishot;
11503 194 }
11504
11505
2/2
✓ Branch 0 taken 2280564 times.
✓ Branch 1 taken 7128159 times.
9408723 if(clk2==0)
11506 {
11507 7128159 multishot = 0;
11508 7128159 }
11509
11510
2/2
✓ Branch 0 taken 9344606 times.
✓ Branch 1 taken 64117 times.
9408723 if(timer) //Fire Octo
11511 {
11512 64117 clk2=15; //this keeps the octo in place until he's done firing
11513
11514
2/2
✓ Branch 0 taken 48413 times.
✓ Branch 1 taken 15704 times.
64117 if(!(timer%4))
11515 {
11516 15704 FireBreath(false);
11517 15704 }
11518
11519 64117 --timer;
11520 64117 }
11521
11522
2/2
✓ Branch 0 taken 9231894 times.
✓ Branch 1 taken 176829 times.
9408723 if(dmisc2==e2tTRIBBLE)
11523 176829 ++clk4;
11524
11525
7/10
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 9406483 times.
✓ Branch 2 taken 607 times.
✓ Branch 3 taken 9408116 times.
✓ Branch 4 taken 607 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 607 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 607 times.
9408723 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11526 {
11527 607 int32_t kids = guys.Count();
11528 607 int32_t id2=dmisc3;
11529
11530
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 607 times.
1214 for(int32_t i=0; i<dmisc4; i++)
11531 {
11532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
607 if(addenemy(x,y,id2,-24))
11533 {
11534
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(itemguy) // Hand down the carried item
11535 {
11536 guycarryingitem = guys.Count()-1;
11537 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11538 itemguy = false;
11539 }
11540
11541 607 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11542 607 }
11543 607 }
11544
11545
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(hashero)
11546 {
11547 Hero.setEaten(0);
11548 hashero=false;
11549 }
11550
11551 607 stop_bgsfx(index);
11552 607 return true;
11553 }
11554
11555 9408116 return enemy::animate(index);
11556 9630028 }
11557
11558 9950483 void eStalfos::draw(BITMAP *dest)
11559 {
11560 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
11561 {
11562 clk4--; //Kludge
11563 return;
11564 }*/
11565
11566 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
11567 {
11568 cs = dcset;
11569 }*/
11570 9950483 update_enemy_frame();
11571
11572
7/8
✓ Branch 0 taken 9950341 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 9950341 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35975 times.
✓ Branch 5 taken 9914366 times.
✓ Branch 6 taken 33085 times.
✓ Branch 7 taken 2890 times.
9950483 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11573 {
11574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if ( do_animation )tile+=20;
11575 2890 }
11576
11577 9950483 enemy::draw(dest);
11578 9950483 }
11579
11580 2685346 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11581 {
11582 2685346 int32_t tempy=yofs;
11583
11584 /*
11585 if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) {
11586 flip = 0;
11587 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11588 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
11589 shadowtile = wpnsbuf[spr_shadow].tile+f2;
11590 yofs+=(((int32_t)y+17)&0xF0)-y;
11591 yofs+=8;
11592 }
11593 */
11594
4/4
✓ Branch 0 taken 2600205 times.
✓ Branch 1 taken 85141 times.
✓ Branch 2 taken 2666214 times.
✓ Branch 3 taken 19132 times.
2685346 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11595 {
11596 19132 flip = 0;
11597 19132 int32_t fdiv = frate/4;
11598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19132 times.
19132 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11599
11600
1/2
✓ Branch 0 taken 19132 times.
✗ Branch 1 not taken.
19132 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11601 19132 efrate:((clk>=(frate>>1))?1:0);
11602 19132 shadowtile = wpnsbuf[spr_shadow].tile;
11603
11604
1/2
✓ Branch 0 taken 19132 times.
✗ Branch 1 not taken.
19132 if(get_qr(qr_NEWENEMYTILES))
11605 {
11606 19132 shadowtile+=f2;
11607 19132 }
11608 else
11609 {
11610 shadowtile+=f2?1:0;
11611 }
11612
11613 19132 yofs+=shadowdistance;
11614 19132 yofs+=8;
11615 19132 }
11616
3/4
✓ Branch 0 taken 2600205 times.
✓ Branch 1 taken 85141 times.
✓ Branch 2 taken 2685346 times.
✗ Branch 3 not taken.
2685346 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11617 {
11618 flip = 0;
11619 int32_t fdiv = frate/4;
11620 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11621
11622 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11623 efrate:((clk>=(frate>>1))?1:0);
11624 shadowtile = wpnsbuf[spr_shadow].tile;
11625
11626 if(get_qr(qr_NEWENEMYTILES))
11627 {
11628 shadowtile+=f2;
11629 }
11630 else
11631 {
11632 shadowtile+=f2?1:0;
11633 }
11634 }
11635
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 2685204 times.
2685346 if(!shadow_overpit(this))
11636 2685204 enemy::drawshadow(dest, translucent);
11637 2685346 yofs=tempy;
11638 2685346 }
11639
11640 98900 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11641 {
11642 98900 int32_t wpnId = w->id;
11643 98900 int32_t wpnDir = w->dir;
11644
11645
4/4
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 98324 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 380 times.
98900 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11646
5/8
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119 times.
✓ Branch 5 taken 77 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 77 times.
196 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
11647
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
11648 {
11649 119 shield = false;
11650 119 flags &= ~(inv_left|inv_right|inv_back|inv_front);
11651
11652
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 14 times.
119 if(get_qr(qr_BRKNSHLDTILES))
11653 14 o_tile=s_tile;
11654 119 }
11655
11656 98900 int32_t ret = enemy::takehit(w,realweap);
11657
11658
4/4
✓ Branch 0 taken 12005 times.
✓ Branch 1 taken 86895 times.
✓ Branch 2 taken 10754 times.
✓ Branch 3 taken 1251 times.
98900 if(sclk && dmisc2==e2tSPLITHIT)
11659 1251 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11660
11661 98900 return ret;
11662 }
11663
11664 649572 void eStalfos::charge_attack()
11665 {
11666
2/2
✓ Branch 0 taken 4921 times.
✓ Branch 1 taken 644651 times.
649572 if(slide())
11667 4921 return;
11668
11669
9/12
✓ Branch 0 taken 644651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 644651 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 622871 times.
✓ Branch 5 taken 21780 times.
✓ Branch 6 taken 604111 times.
✓ Branch 7 taken 18760 times.
✓ Branch 8 taken 599945 times.
✓ Branch 9 taken 4166 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 599945 times.
644651 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11670 44706 return;
11671
11672
2/2
✓ Branch 0 taken 23890 times.
✓ Branch 1 taken 576055 times.
599945 if(clk3<=0)
11673 {
11674 23890 fix_coords(true);
11675
11676
2/2
✓ Branch 0 taken 6397 times.
✓ Branch 1 taken 17493 times.
23890 if(!dashing)
11677 {
11678 17493 int32_t ldir = lined_up(7,false);
11679
11680
4/4
✓ Branch 0 taken 1774 times.
✓ Branch 1 taken 15719 times.
✓ Branch 2 taken 1497 times.
✓ Branch 3 taken 277 times.
17493 if(ldir!=-1 && canmove(ldir,false))
11681 {
11682 1497 dir=ldir;
11683 1497 dashing=true;
11684 1497 step=zslongToFix(dstep*100)+1;
11685 1497 }
11686 15996 else newdir(4,0,0);
11687 17493 }
11688
11689
2/2
✓ Branch 0 taken 23007 times.
✓ Branch 1 taken 883 times.
23890 if(!canmove(dir,false))
11690 {
11691 883 step=zslongToFix(dstep*100);
11692 883 newdir();
11693 883 dashing=false;
11694 883 }
11695
11696 23890 zfix div = step;
11697
11698
1/2
✓ Branch 0 taken 23890 times.
✗ Branch 1 not taken.
23890 if(div == 0)
11699 div = 1;
11700
11701 23890 clk3=(int32_t)(16.0/div);
11702 23890 return;
11703 }
11704
11705 576055 move(step);
11706 576055 --clk3;
11707 649572 }
11708
11709 472060 void eStalfos::vire_hop()
11710 {
11711 //if ( sclk > 0 ) return; //Don't hop during knockback.
11712
11713 // if(dmisc9!=e9tPOLSVOICE)
11714 // {
11715 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11716 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11717 // return; //the enemy should split if it is sliding!
11718 // //else sclk=0; //might need this here, too. -Z
11719 // }
11720
2/2
✓ Branch 0 taken 199058 times.
✓ Branch 1 taken 273002 times.
472060 if(dmisc9!=e9tPOLSVOICE)
11721 {
11722
2/2
✓ Branch 0 taken 193681 times.
✓ Branch 1 taken 5377 times.
199058 if(sclk!=0)
11723 {
11724
2/2
✓ Branch 0 taken 1534 times.
✓ Branch 1 taken 3843 times.
5377 if (dmisc2==e2tSPLITHIT) return;
11725 //return;
11726 3843 }
11727 197524 }
11728 273002 else sclk=0;
11729
11730
8/12
✓ Branch 0 taken 470526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 470526 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 462011 times.
✓ Branch 5 taken 8515 times.
✓ Branch 6 taken 446955 times.
✓ Branch 7 taken 15056 times.
✓ Branch 8 taken 446955 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 446955 times.
470526 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11731 23571 return;
11732
11733 446955 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11734 446955 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
11735
11736 446955 y=floor_y;
11737
11738
2/2
✓ Branch 0 taken 432185 times.
✓ Branch 1 taken 14770 times.
446955 if(clk3<=0)
11739 {
11740 14770 fix_coords();
11741
11742 //z=0;
11743 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11744 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11745
9/10
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 11899 times.
✓ Branch 2 taken 2542 times.
✓ Branch 3 taken 329 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 2448 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
14770 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests
11746 12322 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11747
11748
2/2
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 11899 times.
14770 if(clk2<=0)
11749 {
11750 //z=0;
11751
6/6
✓ Branch 0 taken 10893 times.
✓ Branch 1 taken 1006 times.
✓ Branch 2 taken 10646 times.
✓ Branch 3 taken 247 times.
✓ Branch 4 taken 7845 times.
✓ Branch 5 taken 2801 times.
11899 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11752 {
11753
11754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9098 times.
9098 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11755 /*if (dmisc9==e9tPOLSVOICE )
11756 {
11757 zprint2("polsvoice jump_width is: %d\n", jump_width);
11758 zprint2("polsvoice raw step is: %d\n", step);
11759 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11760 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11761 }
11762 else
11763 {
11764 zprint2("vire jump_width is: %d\n", jump_width);
11765 zprint2("vire raw step is: %d\n", step);
11766 zprint2("vire step.getInt() is: %d\n", step.getInt());
11767 zprint2("setting clk2 on vire to: %d\n", clk2);
11768 }
11769 */
11770 9098 }
11771 11899 }
11772
11773
4/4
✓ Branch 0 taken 6207 times.
✓ Branch 1 taken 8563 times.
✓ Branch 2 taken 2801 times.
✓ Branch 3 taken 3406 times.
14770 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11774 {
11775 3406 clk2=int32_t((16.0*jump_width)/step.getFloat());
11776 3406 }
11777
11778 14770 clk3=int32_t(16.0/step.getFloat());
11779 14770 }
11780
11781 446955 --clk3;
11782
11783
3/4
✓ Branch 0 taken 185954 times.
✓ Branch 1 taken 261001 times.
✓ Branch 2 taken 185954 times.
✗ Branch 3 not taken.
446955 if(dmisc9==e9tPOLSVOICE || clk2>0)
11784 446955 move(step);
11785
11786 446955 floor_y=y;
11787 446955 clk2--;
11788
11789 //if we're in the middle of a jump
11790
6/6
✓ Branch 0 taken 350625 times.
✓ Branch 1 taken 96330 times.
✓ Branch 2 taken 148718 times.
✓ Branch 3 taken 201907 times.
✓ Branch 4 taken 67317 times.
✓ Branch 5 taken 81401 times.
446955 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11791 {
11792 269224 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11793
11794
4/4
✓ Branch 0 taken 97084 times.
✓ Branch 1 taken 172140 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 90933 times.
269224 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11795 {
11796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90933 times.
90933 if (moveflags & FLAG_USE_FAKE_Z) fakez=h;
11797 90933 else z=h;
11798 90933 }
11799 else
11800 {
11801 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11802 //y-=h;
11803 178291 y=floor_y-h;
11804 178291 shadowdistance=h;
11805 }
11806 269224 }
11807 else
11808 177731 shadowdistance = 0;
11809 472060 }
11810
11811 51 void eStalfos::eathero()
11812 {
11813
5/8
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 32 times.
51 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11814 {
11815 32 hashero=true;
11816 32 y=floor_y;
11817 32 z=0;
11818
11819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(Hero.isSwimming())
11820 {
11821 Hero.setX(x);
11822 Hero.setY(y);
11823 }
11824 else
11825 {
11826 32 x=Hero.getX();
11827 32 y=Hero.getY();
11828 }
11829
11830 32 clk2=0;
11831 32 }
11832 51 }
11833
11834 983776 bool eStalfos::WeaponOut()
11835 {
11836
2/2
✓ Branch 0 taken 1749223 times.
✓ Branch 1 taken 412425 times.
2161648 for(int32_t i=0; i<Ewpns.Count(); i++)
11837 {
11838
3/4
✓ Branch 0 taken 571351 times.
✓ Branch 1 taken 1177872 times.
✓ Branch 2 taken 571351 times.
✗ Branch 3 not taken.
1749223 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11839 {
11840 571351 return true;
11841 }
11842
11843 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
11844 stop_sfx(bgsfx);
11845 */
11846 1177872 }
11847
11848 412425 return false;
11849 983776 }
11850
11851 207899 void eStalfos::KillWeapon()
11852 {
11853
2/2
✓ Branch 0 taken 207899 times.
✓ Branch 1 taken 188444 times.
396343 for(int32_t i=0; i<Ewpns.Count(); i++)
11854 {
11855
4/4
✓ Branch 0 taken 159094 times.
✓ Branch 1 taken 29350 times.
✓ Branch 2 taken 158567 times.
✓ Branch 3 taken 527 times.
188444 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11856 {
11857 //only kill this Goriya's boomerang -DD
11858
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 234 times.
527 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11859 {
11860 234 Ewpns.del(i);
11861 234 }
11862 527 }
11863 188444 }
11864
11865
4/4
✓ Branch 0 taken 17536 times.
✓ Branch 1 taken 190363 times.
✓ Branch 2 taken 8819 times.
✓ Branch 3 taken 8717 times.
207899 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
11866 {
11867 8819 stop_sfx(WAV_BRANG);
11868 8819 }
11869 207899 }
11870
11871 void eStalfos::break_shield()
11872 {
11873 if(!shield)
11874 return;
11875
11876 flags&=~(inv_front | inv_back | inv_left | inv_right);
11877 shield=false;
11878
11879 if(get_qr(qr_BRKNSHLDTILES))
11880 o_tile=s_tile;
11881 }
11882
11883 6621 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11884 6621 {
11885
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 dir=(zc_oldrand()&7)+8;
11886
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 step=0;
11887 6621 movestatus=1;
11888
3/4
✓ Branch 0 taken 5596 times.
✓ Branch 1 taken 1025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5596 times.
6621 if (dmisc1 != 1 && dmisc19 > 0)
11889 {
11890 step = dmisc19/100.0;
11891 movestatus = 1;
11892 }
11893
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if (dmisc1 == 2) movestatus=2;
11894 6621 c=0;
11895 6621 SIZEflags = d->SIZEflags;
11896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2;
11897
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11898
11899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hit_width=12;
11900
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
11901
11902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4;
11903
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11904
11905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hit_height=8;
11906
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
11907
11908
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11909 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
11910 // al_trace("Enemy txsz:%i\n", txsz);
11911
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11912
11913
11914
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
11915
11916
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11918 {
11919 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11920 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11921 }
11922
11923
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11924 6621 clk4=0;
11925 //nets;
11926 6621 dummy_int[1]=0;
11927 6621 }
11928
11929 1835461 bool eKeese::animate(int32_t index)
11930 {
11931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1835461 times.
1835461 if(switch_hooked) return enemy::animate(index);
11932
2/4
✓ Branch 0 taken 1835461 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1835461 times.
1835461 if(fallclk||drownclk) return enemy::animate(index);
11933
2/2
✓ Branch 0 taken 68910 times.
✓ Branch 1 taken 1766551 times.
1835461 if(dying)
11934 68910 return Dead(index);
11935
11936
2/2
✓ Branch 0 taken 15740 times.
✓ Branch 1 taken 1750811 times.
1766551 if(clk==0)
11937 {
11938 15740 removearmos(x,y,ffcactivated);
11939 15740 }
11940
11941
2/2
✓ Branch 0 taken 382128 times.
✓ Branch 1 taken 1384423 times.
1766551 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11942 {
11943 382128 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11944 382128 }
11945 else
11946 {
11947
1/2
✓ Branch 0 taken 1384423 times.
✗ Branch 1 not taken.
1384423 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11948 1384423 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11949 }
11950
11951
2/2
✓ Branch 0 taken 35781 times.
✓ Branch 1 taken 1730770 times.
1766551 if(dmisc2 == e2tKEESETRIB)
11952 {
11953
3/4
✓ Branch 0 taken 35781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35710 times.
✓ Branch 3 taken 71 times.
35781 if(++clk4==(dmisc20>0?dmisc20:256))
11954 {
11955
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 53 times.
71 if(!m_walkflag(x,y,0, dir))
11956 {
11957 53 int32_t kids = guys.Count();
11958 53 bool success = false;
11959 53 int32_t id2=dmisc3;
11960 53 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
11961
11962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(success)
11963 {
11964
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if(itemguy) // Hand down the carried item
11965 {
11966 guycarryingitem = guys.Count()-1;
11967 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11968 itemguy = false;
11969 }
11970
11971 53 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11972 53 }
11973
11974 53 stop_bgsfx(index);
11975 53 return true;
11976 }
11977 else
11978 {
11979 18 clk4=0;
11980 }
11981 18 }
11982 35728 }
11983 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11984
3/4
✓ Branch 0 taken 483168 times.
✓ Branch 1 taken 1247602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 483168 times.
1730770 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11985 {
11986
1/2
✓ Branch 0 taken 483168 times.
✗ Branch 1 not taken.
483168 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11987 {
11988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483168 times.
483168 if (moveflags & FLAG_USE_FAKE_Z)
11989 {
11990 fakez=int32_t(step/zslongToFix(dstep*100));
11991 // Some variance in keese flight heights when away from Hero
11992 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11993
11994 }
11995 else
11996 {
11997 483168 z=int32_t(step/zslongToFix(dstep*100));
11998 // Some variance in keese flight heights when away from Hero
11999
2/2
✓ Branch 0 taken 392481 times.
✓ Branch 1 taken 90687 times.
483168 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
12000 }
12001 483168 }
12002 else
12003 {
12004 if (moveflags & FLAG_USE_FAKE_Z)
12005 {
12006 fakez=int32_t(step/zslongToFix(dstep*100));
12007 // Some variance in keese flight heights when away from Hero
12008 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
12009
12010 }
12011 else
12012 {
12013 z=int32_t(step/zslongToFix(dstep*100));
12014 // Some variance in keese flight heights when away from Hero
12015 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
12016 }
12017 }
12018 483168 }
12019
12020 1766498 return enemy::animate(index);
12021 1835461 }
12022
12023 561528 void eKeese::drawshadow(BITMAP *dest, bool translucent)
12024 {
12025 561528 int32_t tempy=yofs;
12026 561528 flip = 0;
12027 561528 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
12028
12029
2/2
✓ Branch 0 taken 214011 times.
✓ Branch 1 taken 347517 times.
561528 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
12030
2/2
✓ Branch 0 taken 302522 times.
✓ Branch 1 taken 259006 times.
561528 if(!get_qr(qr_ENEMIESZAXIS))
12031 {
12032 259006 yofs+=int32_t(step/zslongToFix(dstep*10));
12033 259006 }
12034
12035
6/6
✓ Branch 0 taken 557934 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 302522 times.
✓ Branch 3 taken 255412 times.
✓ Branch 4 taken 294452 times.
✓ Branch 5 taken 8070 times.
561528 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
12036 549864 enemy::drawshadow(dest, translucent);
12037 561528 yofs=tempy;
12038 561528 }
12039
12040 4144206 void eKeese::draw(BITMAP *dest)
12041 {
12042 4144206 update_enemy_frame();
12043 4144206 enemy::draw(dest);
12044 4144206 }
12045
12046 11346 void eWizzrobe::submerge(bool set)
12047 {
12048
2/2
✓ Branch 0 taken 11318 times.
✓ Branch 1 taken 28 times.
11346 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
12049 {
12050 11318 hxofs = set?1000:0;
12051 11318 return;
12052 }
12053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(submerged == set) return;
12054 28 submerged = set;
12055
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(set)
12056 14 hxofs+=1000;
12057 14 else hxofs -= 1000;
12058 11346 }
12059 2150 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12060 2150 {
12061 2150 hxofs = 0;
12062 2150 submerged = false;
12063
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 1230 times.
2150 switch(dmisc1)
12064 {
12065 case 0:
12066 1230 submerge(true);
12067 1230 fading=fade_invisible;
12068 // Set clk to just before the 'reappear' threshold
12069
6/10
✓ Branch 0 taken 1230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 960 times.
✓ Branch 5 taken 270 times.
✓ Branch 6 taken 960 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 270 times.
✗ Branch 9 not taken.
1230 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
12070 1230 break;
12071
12072 default:
12073 920 dir=(loadside==right)?right:left;
12074 920 misc=-3;
12075 920 break;
12076 }
12077
12078 //netst+2880;
12079 2150 charging=false;
12080 2150 firing=false;
12081 2150 fclk=0;
12082
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 1230 times.
2150 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
12083 2150 SIZEflags = d->SIZEflags;
12084
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12085 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12086 // al_trace("Enemy txsz:%i\n", txsz);
12087
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12088
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
12089
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
12090
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12091
1/2
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 )
12092 {
12093 hxofs = (submerged?hxofs:0)+d->hxofs;
12094 }
12095
1/2
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12096 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12097
1/4
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12099 {
12100 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12101 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12102 }
12103
12104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12105 2150 }
12106
12107 1015605 bool eWizzrobe::animate(int32_t index)
12108 {
12109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1015605 times.
1015605 if(switch_hooked) return enemy::animate(index);
12110
2/4
✓ Branch 0 taken 1015605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1015605 times.
1015605 if(fallclk||drownclk) return enemy::animate(index);
12111
2/2
✓ Branch 0 taken 21786 times.
✓ Branch 1 taken 993819 times.
1015605 if(dying)
12112 {
12113 21786 return Dead(index);
12114 }
12115
12116
2/2
✓ Branch 0 taken 962127 times.
✓ Branch 1 taken 31692 times.
993819 if(clk==0)
12117 {
12118 31692 removearmos(x,y,ffcactivated);
12119 31692 }
12120
12121
2/2
✓ Branch 0 taken 502494 times.
✓ Branch 1 taken 491325 times.
993819 if(dmisc1) // Floating
12122 {
12123 502494 wizzrobe_attack();
12124 502494 }
12125 else // Teleporting
12126 {
12127
5/6
✓ Branch 0 taken 485972 times.
✓ Branch 1 taken 5353 times.
✓ Branch 2 taken 2710 times.
✓ Branch 3 taken 483262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2710 times.
491325 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
12128 {
12129 5353 fading=0;
12130 5353 submerge(false);
12131 5353 solid_update(false);
12132 5353 }
12133
8/8
✓ Branch 0 taken 469803 times.
✓ Branch 1 taken 2887 times.
✓ Branch 2 taken 2507 times.
✓ Branch 3 taken 2430 times.
✓ Branch 4 taken 2393 times.
✓ Branch 5 taken 2075 times.
✓ Branch 6 taken 2001 times.
✓ Branch 7 taken 1876 times.
485972 else switch(clk)
12134 {
12135 case 0:
12136
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 2406 times.
2887 if(!dmisc2)
12137 {
12138 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
12139 // but should not appear on dungeon walls.
12140
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 1997 times.
2406 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
12141
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1925 times.
1997 else if (editorflags&ENEMY_FLAG5)
12142 {
12143 //2.10 Windrobe
12144 //randomise location and face Hero
12145 72 int32_t t=0;
12146 72 bool placed=false;
12147
12148
4/4
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 72 times.
178 while(!placed && t<160)
12149 {
12150
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 55 times.
106 if(isdungeon())
12151 {
12152 51 x=((zc_oldrand()%12)+2)*16;
12153 51 y=((zc_oldrand()%7)+2)*16;
12154 51 }
12155 else
12156 {
12157 55 x=((zc_oldrand()%14)+1)*16;
12158 55 y=((zc_oldrand()%9)+1)*16;
12159 }
12160
12161
6/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 72 times.
184 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12162 {
12163 72 placed=true;
12164 72 }
12165
12166 106 ++t;
12167 }
12168
12169
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 46 times.
72 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12170 {
12171
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5 times.
26 if(y<Hero.getY())
12172 {
12173 21 dir=down;
12174 21 }
12175 else
12176 {
12177 5 dir=up;
12178 }
12179 26 }
12180 else
12181 {
12182
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 25 times.
46 if(x<Hero.getX())
12183 {
12184 25 dir=right;
12185 25 }
12186 else
12187 {
12188 21 dir=left;
12189 }
12190 }
12191
12192
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(!placed) // can't place him, he's gone
12193 return true;
12194
12195
12196 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
12197 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
12198 72 }
12199 1925 else place_on_axis(true, dmisc4!=0);
12200 2406 }
12201 else
12202 {
12203 481 int32_t t=0;
12204 481 bool placed=false;
12205
12206
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 641 times.
✓ Branch 3 taken 481 times.
1122 while(!placed && t<160)
12207 {
12208
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 17 times.
641 if(isdungeon())
12209 {
12210 624 x=((zc_oldrand()%12)+2)*16;
12211 624 y=((zc_oldrand()%7)+2)*16;
12212 624 }
12213 else
12214 {
12215 17 x=((zc_oldrand()%14)+1)*16;
12216 17 y=((zc_oldrand()%9)+1)*16;
12217 }
12218
12219
6/6
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 389 times.
✓ Branch 3 taken 165 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 481 times.
1195 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12220 {
12221 481 placed=true;
12222 481 }
12223
12224 641 ++t;
12225 }
12226
12227
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 322 times.
481 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12228 {
12229
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 62 times.
159 if(y<Hero.getY())
12230 {
12231 97 dir=down;
12232 97 }
12233 else
12234 {
12235 62 dir=up;
12236 }
12237 159 }
12238 else
12239 {
12240
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 156 times.
322 if(x<Hero.getX())
12241 {
12242 166 dir=right;
12243 166 }
12244 else
12245 {
12246 156 dir=left;
12247 }
12248 }
12249
12250
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(!placed) // can't place him, he's gone
12251 return true;
12252 }
12253
12254 2887 fading=fade_flicker;
12255 2887 submerge(false);
12256 2887 solid_update(false);
12257 2887 break;
12258
12259 case 64:
12260 2507 fading=0;
12261 2507 charging=true;
12262 2507 break;
12263
12264 case 73:
12265 2430 charging=false;
12266 2430 firing=40;
12267 2430 break;
12268
12269 case 83:
12270 2393 wizzrobe_attack_for_real();
12271 2393 break;
12272
12273 case 119:
12274 2075 firing=false;
12275 2075 charging=true;
12276 2075 break;
12277
12278 case 128:
12279 2001 fading=fade_flicker;
12280 2001 charging=false;
12281 2001 break;
12282
12283 case 146:
12284 1876 fading=fade_invisible;
12285 1876 submerge(true);
12286 1876 solid_update(false);
12287
12288 [[fallthrough]];
12289 default:
12290
3/4
✓ Branch 0 taken 471679 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 468788 times.
✓ Branch 3 taken 2891 times.
471679 if(clk>=(146+zc_max(0,dmisc5)))
12291 2891 clk=-1;
12292
12293 471679 break;
12294 }
12295 }
12296
12297 993819 return enemy::animate(index);
12298 1015605 }
12299
12300 3874 void eWizzrobe::wizzrobe_attack_for_real()
12301 {
12302
1/2
✓ Branch 0 taken 3874 times.
✗ Branch 1 not taken.
3874 if(wpn==0) // Edited enemies
12303 return;
12304
12305
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 3069 times.
3874 if(dmisc2 == 0) //normal weapon
12306 {
12307 3069 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
12308 3069 sfx(WAV_WAND,pan(int32_t(x)));
12309 3069 }
12310
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 450 times.
805 else if(dmisc2 == 1) // ring of fire
12311 {
12312 355 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
12313 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12314 355 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
12315 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12316 355 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
12317 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12318 355 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
12319 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12320 355 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
12321 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12322 355 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
12323 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12324 355 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
12325 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12326 355 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
12327 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12328 355 sfx(WAV_FIRE,pan(int32_t(x)));
12329
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 283 times.
355 if (get_qr(qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
12330 else
12331 {
12332
2/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 264 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
283 switch(wpn)
12333 {
12334 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
12335
12336 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
12337 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
12338 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
12339 case ewRock: sfx(51,pan(int32_t(x))); break;
12340 case ewMagic: sfx(32,pan(int32_t(x))); break;
12341 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12342 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12343 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12344 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12345 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
12346 264 case ewFlame: sfx(13,pan(int32_t(x))); break;
12347 case ewWind: sfx(32,pan(int32_t(x))); break;
12348 case ewFlame2: sfx(13,pan(int32_t(x))); break;
12349 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
12350 case ewIce: sfx(44,pan(int32_t(x))); break;
12351 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
12352 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
12353
12354 }
12355 }
12356 355 }
12357
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 14 times.
450 else if(dmisc2==2) // summons specific enemy
12358 {
12359 436 int32_t bc=0;
12360
12361
2/2
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 436 times.
5830 for(int32_t gc=0; gc<guys.Count(); gc++)
12362 {
12363
2/2
✓ Branch 0 taken 2590 times.
✓ Branch 1 taken 2804 times.
5394 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12364 {
12365 2804 ++bc;
12366 2804 }
12367 5394 }
12368
12369
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 428 times.
436 if(bc<=40)
12370 {
12371 428 int32_t kids = guys.Count();
12372 428 int32_t bats=(zc_oldrand()%3)+1;
12373
12374
2/2
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 428 times.
1296 for(int32_t i=0; i<bats; i++)
12375 {
12376 // Summon bats (or anything)
12377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 868 times.
868 if(addchild(x,y,dmisc3,-10, this->script_UID))
12378 868 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12379 868 }
12380
12381 428 sfx(WAV_FIRE,pan(int32_t(x)));
12382 428 }
12383 436 }
12384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(dmisc2==3) //summon from layer
12385 {
12386
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count_layer_enemies()==0)
12387 {
12388 return;
12389 }
12390
12391 14 int32_t kids = guys.Count();
12392
12393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(kids<200)
12394 {
12395 14 int32_t newguys=(zc_oldrand()%3)+1;
12396 14 bool summoned=false;
12397
12398
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14 times.
39 for(int32_t i=0; i<newguys; i++)
12399 {
12400 25 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
12401 25 int32_t x2=0;
12402 25 int32_t y2=0;
12403
12404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t k=0; k<20; ++k)
12405 {
12406 27 x2=16*((zc_oldrand()%12)+2);
12407 27 y2=16*((zc_oldrand()%7)+2);
12408
12409
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 25 times.
54 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12410 {
12411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
12412 {
12413 25 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
12415 {
12416 ((enemy*)guys.spr(kids+i))->fakez = 64;
12417 ((enemy*)guys.spr(kids+i))->z = 0;
12418 }
12419 25 }
12420
12421 25 summoned=true;
12422 25 break;
12423 }
12424 2 }
12425 25 }
12426
12427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(summoned)
12428 {
12429 14 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
12430 14 }
12431 14 }
12432 14 }
12433 3874 }
12434
12435
12436 502494 void eWizzrobe::wizzrobe_attack()
12437 {
12438
9/12
✓ Branch 0 taken 487591 times.
✓ Branch 1 taken 14903 times.
✓ Branch 2 taken 487591 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 468976 times.
✓ Branch 5 taken 18615 times.
✓ Branch 6 taken 466825 times.
✓ Branch 7 taken 2151 times.
✓ Branch 8 taken 466825 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 466825 times.
502494 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12439 35669 return;
12440
12441
3/8
✓ Branch 0 taken 448202 times.
✓ Branch 1 taken 18623 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 448202 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
466825 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12442 {
12443 18623 fix_coords();
12444
12445
5/5
✓ Branch 0 taken 2316 times.
✓ Branch 1 taken 603 times.
✓ Branch 2 taken 8722 times.
✓ Branch 3 taken 4845 times.
✓ Branch 4 taken 2137 times.
18623 switch(misc)
12446 {
12447 case 1: //walking
12448
2/2
✓ Branch 0 taken 3698 times.
✓ Branch 1 taken 1147 times.
4845 if(!m_walkflag(x,y,spw_door, dir))
12449 1147 misc=0;
12450 else
12451 {
12452 3698 clk3=16;
12453
12454
2/2
✓ Branch 0 taken 3185 times.
✓ Branch 1 taken 513 times.
3698 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12455 {
12456 513 wizzrobe_newdir(0);
12457 513 }
12458 }
12459
12460 4845 break;
12461
12462 case 2: //phasing
12463 {
12464 2137 int32_t jx=x;
12465 2137 int32_t jy=y;
12466 2137 int32_t jdir=-1;
12467
12468
5/5
✓ Branch 0 taken 1083 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 245 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 266 times.
2137 switch(zc_oldrand()&7)
12469 {
12470 case 0:
12471 279 jx-=32;
12472 279 jy-=32;
12473 279 jdir=15;
12474 279 break;
12475
12476 case 1:
12477 245 jx+=32;
12478 245 jy-=32;
12479 245 jdir=9;
12480 245 break;
12481
12482 case 2:
12483 264 jx+=32;
12484 264 jy+=32;
12485 264 jdir=11;
12486 264 break;
12487
12488 case 3:
12489 266 jx-=32;
12490 266 jy+=32;
12491 266 jdir=13;
12492 266 break;
12493 }
12494
12495
10/10
✓ Branch 0 taken 1054 times.
✓ Branch 1 taken 1083 times.
✓ Branch 2 taken 940 times.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 876 times.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 763 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 633 times.
✓ Branch 9 taken 130 times.
2137 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12496 {
12497 633 misc=3;
12498 633 clk3=32;
12499 633 dir=jdir;
12500 633 break;
12501 }
12502 1504 }
12503 [[fallthrough]];
12504 case 3:
12505 2107 dir&=3;
12506 2107 misc=0;
12507 [[fallthrough]];
12508 case 0:
12509 10829 wizzrobe_newdir(64);
12510 [[fallthrough]];
12511 default:
12512
2/2
✓ Branch 0 taken 11753 times.
✓ Branch 1 taken 1392 times.
13145 if(!canmove(dir,(zfix)1,spw_door,false))
12513 {
12514
2/2
✓ Branch 0 taken 1326 times.
✓ Branch 1 taken 66 times.
1392 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12515 {
12516 1326 misc=1;
12517 1326 clk3=16;
12518 1326 }
12519 else
12520 {
12521 66 wizzrobe_newdir(64);
12522 66 misc=0;
12523 66 clk3=32;
12524 }
12525 1392 }
12526 else
12527 {
12528 11753 clk3=32;
12529 }
12530
12531 13145 break;
12532 }
12533
12534
2/2
✓ Branch 0 taken 16596 times.
✓ Branch 1 taken 2027 times.
18623 if(misc<0)
12535 2027 ++misc;
12536 18623 }
12537
12538 466825 --clk3;
12539
12540
3/3
✓ Branch 0 taken 98770 times.
✓ Branch 1 taken 332655 times.
✓ Branch 2 taken 35400 times.
466825 switch(misc)
12541 {
12542 case 1:
12543 case 3:
12544 98770 step=1;
12545 98770 break;
12546
12547 case 2:
12548 35400 step=0;
12549 35400 break;
12550
12551 default:
12552 332655 step=0.5;
12553 332655 break;
12554
12555 }
12556
12557 466825 move(step);
12558
12559 // if(d->misc1 && misc<=0 && clk3==28)
12560
5/6
✓ Branch 0 taken 466825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332655 times.
✓ Branch 3 taken 134170 times.
✓ Branch 4 taken 321156 times.
✓ Branch 5 taken 11499 times.
466825 if(dmisc1 && misc<=0 && clk3==28)
12561 {
12562
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 1619 times.
11499 if(dmisc2 != 1)
12563 {
12564
2/2
✓ Branch 0 taken 8754 times.
✓ Branch 1 taken 1126 times.
9880 if(lined_up(8,false) == dir)
12565 {
12566 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12567 // sfx(WAV_WAND,pan(int32_t(x)));
12568 1126 wizzrobe_attack_for_real();
12569 1126 fclk=30;
12570 1126 }
12571 9880 }
12572 else
12573 {
12574
2/2
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 355 times.
1619 if((zc_oldrand()%500)>=400)
12575 {
12576 355 wizzrobe_attack_for_real();
12577 355 fclk=30;
12578 355 }
12579 }
12580 11499 }
12581
12582
4/4
✓ Branch 0 taken 287050 times.
✓ Branch 1 taken 179775 times.
✓ Branch 2 taken 2200 times.
✓ Branch 3 taken 284850 times.
466825 if(misc==0 && (zc_oldrand()&127)==0)
12583 2200 misc=2;
12584
12585
4/4
✓ Branch 0 taken 37600 times.
✓ Branch 1 taken 429225 times.
✓ Branch 2 taken 35712 times.
✓ Branch 3 taken 1888 times.
466825 if(misc==2 && clk3==4)
12586 1888 fix_coords();
12587
12588
2/4
✓ Branch 0 taken 466825 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466825 times.
466825 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12589 {
12590
2/2
✓ Branch 0 taken 424649 times.
✓ Branch 1 taken 42176 times.
466825 if(fclk>0)
12591 {
12592 42176 --fclk;
12593 42176 }
12594 466825 }
12595
12596 502494 }
12597
12598 11408 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12599 {
12600 // Wizzrobes shouldn't move to the edge of the screen;
12601 // if they're already there, they should move toward the center
12602
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11404 times.
11408 if(x<32)
12603 4 dir=right;
12604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
11404 else if(x>=224)
12605 dir=left;
12606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
11404 else if(y<32)
12607 dir=down;
12608
1/2
✓ Branch 0 taken 11404 times.
✗ Branch 1 not taken.
11404 else if(y>=144)
12609 dir=up;
12610 else
12611 11404 newdir(4,homing,spw_wizzrobe);
12612 11408 }
12613
12614 1018464 void eWizzrobe::draw(BITMAP *dest)
12615 {
12616 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12617
13/14
✓ Branch 0 taken 512388 times.
✓ Branch 1 taken 506076 times.
✓ Branch 2 taken 428953 times.
✓ Branch 3 taken 83435 times.
✓ Branch 4 taken 53103 times.
✓ Branch 5 taken 459285 times.
✓ Branch 6 taken 52418 times.
✓ Branch 7 taken 685 times.
✓ Branch 8 taken 51661 times.
✓ Branch 9 taken 757 times.
✓ Branch 10 taken 49440 times.
✓ Branch 11 taken 2221 times.
✓ Branch 12 taken 49440 times.
✗ Branch 13 not taken.
1018464 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12618 49440 return;
12619
12620 969024 int32_t tempint=dummy_int[1];
12621 969024 bool tempbool1=dummy_bool[1];
12622 969024 bool tempbool2=dummy_bool[2];
12623 969024 dummy_int[1]=fclk;
12624 969024 dummy_bool[1]=charging;
12625 969024 dummy_bool[2]=firing;
12626 969024 update_enemy_frame();
12627 969024 dummy_int[1]=tempint;
12628 969024 dummy_bool[1]=tempbool1;
12629 969024 dummy_bool[2]=tempbool2;
12630 969024 enemy::draw(dest);
12631 1018464 }
12632
12633 /*********************************/
12634 /********** Bosses ***********/
12635 /*********************************/
12636
12637 139 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12638 139 {
12639 139 fading=fade_flash_die;
12640 //nets+5120;
12641
6/8
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 31 times.
139 if(dir==down&&y>=128)
12642 {
12643 3 dir=up;
12644 3 }
12645
12646
5/8
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41 times.
✗ Branch 7 not taken.
139 if(dir==right&&x>=208)
12647 {
12648 dir=left;
12649 }
12650 139 SIZEflags = d->SIZEflags;
12651
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12652 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12653 // al_trace("Enemy txsz:%i\n", txsz);
12654
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12655
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12656
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12657
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12658
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12659
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12660 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12661
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12663 {
12664 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12665 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12666 }
12667
12668
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12669 139 }
12670
12671 94046 bool eDodongo::animate(int32_t index)
12672 {
12673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94046 times.
94046 if(switch_hooked) return enemy::animate(index);
12674
2/2
✓ Branch 0 taken 3170 times.
✓ Branch 1 taken 90876 times.
94046 if(dying)
12675 {
12676 3170 return Dead(index);
12677 }
12678
12679
2/2
✓ Branch 0 taken 90462 times.
✓ Branch 1 taken 414 times.
90876 if(clk==0)
12680 {
12681 414 removearmos(x,y,ffcactivated);
12682 414 }
12683
12684
2/2
✓ Branch 0 taken 8736 times.
✓ Branch 1 taken 82140 times.
90876 if(clk2) // ate a bomb
12685 {
12686
2/2
✓ Branch 0 taken 8645 times.
✓ Branch 1 taken 91 times.
8736 if(--clk2==0)
12687 91 hp-=misc; // store bomb's power in misc
12688 8736 }
12689 else
12690 82140 constant_walk(rate,homing,spw_clipright);
12691
12692 90876 hit_width = (dir<=down) ? 16 : 32;
12693 // hysz = (dir>=left) ? 16 : 32;
12694
12695 90876 return enemy::animate(index);
12696 94046 }
12697
12698 94037 void eDodongo::draw(BITMAP *dest)
12699 {
12700 94037 tile=o_tile;
12701
12702
2/2
✓ Branch 0 taken 2272 times.
✓ Branch 1 taken 91765 times.
94037 if(clk<0)
12703 {
12704 2272 enemy::drawzcboss(dest);
12705 2272 return;
12706 }
12707
12708 91765 update_enemy_frame();
12709 91765 enemy::drawzcboss(dest);
12710
12711
2/2
✓ Branch 0 taken 37532 times.
✓ Branch 1 taken 54233 times.
91765 if(dummy_int[1]!=0) //additional tiles
12712 {
12713 54233 tile+=dummy_int[1]; //second tile is previous tile
12714 54233 xofs-=16; //new xofs change
12715 54233 enemy::drawzcboss(dest);
12716 54233 xofs+=16;
12717 54233 }
12718
12719 94037 }
12720
12721 6225 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12722 {
12723 6225 int32_t wpnId = w->id;
12724 6225 int32_t power = w->power;
12725 6225 int32_t wpnx = w->x;
12726 6225 int32_t wpny = w->y;
12727
12728
5/12
✓ Branch 0 taken 6225 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6225 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1749 times.
✓ Branch 5 taken 4476 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1749 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
6225 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12729 4476 return 0;
12730
12731
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
✓ Branch 2 taken 1028 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 98 times.
1749 switch(wpnId)
12732 {
12733 case wPhantom:
12734 return 0;
12735
12736 case wFire:
12737 case wBait:
12738 case wWhistle:
12739 case wWind:
12740 case wSSparkle:
12741 case wFSparkle:
12742 return 0;
12743
12744 case wLitBomb:
12745 case wLitSBomb:
12746
6/6
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 397 times.
✓ Branch 2 taken 238 times.
✓ Branch 3 taken 369 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 91 times.
607 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12747 516 return 0;
12748
12749 91 clk2=96;
12750 91 misc=power;
12751
12752
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 3 times.
91 if(wpnId==wLitSBomb)
12753 3 item_set=isSBOMB100;
12754
12755 91 return 1;
12756
12757 case wBomb:
12758 case wSBomb:
12759
6/6
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 633 times.
✓ Branch 2 taken 289 times.
✓ Branch 3 taken 739 times.
✓ Branch 4 taken 361 times.
✓ Branch 5 taken 667 times.
1028 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12760 361 return 0;
12761
12762 667 stunclk=160;
12763 667 misc=wpnId; // store wpnId
12764 667 return 1;
12765
12766 case wSword:
12767
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 67 times.
98 if(stunclk)
12768 {
12769 67 sfx(WAV_EHIT,pan(int32_t(x)));
12770 67 hp=0;
12771 67 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12772 67 fading=0; // don't flash
12773 67 return 1;
12774 }
12775
12776 [[fallthrough]];
12777 default:
12778 47 sfx(WAV_CHINK,pan(int32_t(x)));
12779 47 }
12780
12781 47 return 1;
12782 6225 }
12783
12784 2 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12785 2 {
12786 2 fading=fade_flash_die;
12787 //nets+5180;
12788 2 previous_dir=-1;
12789
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
2 if(dir==down&&y>=128)
12790 {
12791 dir=up;
12792 }
12793
12794
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==right&&x>=208)
12795 {
12796 dir=left;
12797 }
12798 2 SIZEflags = d->SIZEflags;
12799
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12800 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12801 // al_trace("Enemy txsz:%i\n", txsz);
12802
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12803
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12804
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12805
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12806
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12807
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12808 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12809
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12811 {
12812 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12813 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12814 }
12815
12816
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12817 2 }
12818
12819 848 bool eDodongo2::animate(int32_t index)
12820 {
12821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
848 if(switch_hooked) return enemy::animate(index);
12822
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 812 times.
848 if(dying)
12823 {
12824 36 return Dead(index);
12825 }
12826
12827
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 4 times.
812 if(clk==0)
12828 {
12829 4 removearmos(x,y,ffcactivated);
12830 4 }
12831
12832
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 620 times.
812 if(clk2) // ate a bomb
12833 {
12834
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 2 times.
192 if(--clk2==0)
12835 2 hp-=misc; // store bomb's power in misc
12836 192 }
12837 else
12838 620 constant_walk(rate,homing,spw_clipbottomright);
12839
12840 812 hit_width = (dir<=down) ? 16 : 32;
12841 812 hit_height = (dir>=left) ? 16 : 32;
12842 812 hxofs=(dir>=left)?-8:0;
12843 812 hyofs=(dir<left)?-8:0;
12844
12845 812 return enemy::animate(index);
12846 848 }
12847
12848 848 void eDodongo2::draw(BITMAP *dest)
12849 {
12850
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 818 times.
848 if(clk<0)
12851 {
12852 30 enemy::drawzcboss(dest);
12853 30 return;
12854 }
12855
12856 818 int32_t tempx=xofs;
12857 818 int32_t tempy=yofs;
12858 818 update_enemy_frame();
12859 818 enemy::drawzcboss(dest);
12860 818 tile+=dummy_int[1]; //second tile change
12861 818 xofs+=dummy_int[2]; //new xofs change
12862 818 yofs+=dummy_int[3]; //new yofs change
12863 818 enemy::drawzcboss(dest);
12864 818 xofs=tempx;
12865 818 yofs=tempy;
12866 848 }
12867
12868 165 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12869 {
12870 165 int32_t wpnId = w->id;
12871 165 int32_t power = w->power;
12872 165 int32_t wpnx = w->x;
12873 165 int32_t wpny = w->y;
12874
12875
5/8
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 145 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
165 if(dying || clk<0 || clk2>0 || superman)
12876 145 return 0;
12877
12878
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
20 switch(wpnId)
12879 {
12880 case wPhantom:
12881 return 0;
12882
12883 case wFire:
12884 case wBait:
12885 case wWhistle:
12886 case wWind:
12887 case wSSparkle:
12888 case wFSparkle:
12889 return 0;
12890
12891 case wLitBomb:
12892 case wLitSBomb:
12893
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 switch(dir)
12894 {
12895 case up:
12896 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12897 return 0;
12898
12899 break;
12900
12901 case down:
12902 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12903 return 0;
12904
12905 break;
12906
12907 case left:
12908
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12909 return 0;
12910
12911 2 break;
12912
12913 case right:
12914 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12915 return 0;
12916
12917 break;
12918 }
12919
12920 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12921 // return 0;
12922 2 clk2=96;
12923 2 misc=power;
12924
12925
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(wpnId==wLitSBomb)
12926 item_set=isSBOMB100;
12927
12928 2 return 1;
12929
12930 case wBomb:
12931 case wSBomb:
12932
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
15 switch(dir)
12933 {
12934 case up:
12935 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12936 return 0;
12937
12938 break;
12939
12940 case down:
12941 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12942 return 0;
12943
12944 break;
12945
12946 case left:
12947
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12948 return 0;
12949
12950 15 break;
12951
12952 case right:
12953 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12954 return 0;
12955
12956 break;
12957 }
12958
12959 15 stunclk=160;
12960 15 misc=wpnId; // store wpnId
12961 15 return 1;
12962
12963 case wSword:
12964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(stunclk)
12965 {
12966 2 sfx(WAV_EHIT,pan(int32_t(x)));
12967 2 hp=0;
12968 2 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12969 2 fading=0; // don't flash
12970 2 return 1;
12971 }
12972
12973 [[fallthrough]];
12974 default:
12975 1 sfx(WAV_CHINK,pan(int32_t(x)));
12976 1 }
12977
12978 1 return 1;
12979 165 }
12980
12981 76 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12982 76 {
12983 //these are here to bypass compiler warnings about unused arguments
12984
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( !(editorflags & ENEMY_FLAG5) )
12985 {
12986
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 x = dmisc1 ? 64 : 176;
12987
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 y = 64;
12988 76 }
12989 else { x = X; y = Y; }
12990
12991 //nets+5940;
12992
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 33 times.
76 if(get_qr(qr_NEWENEMYTILES))
12993 {
12994 43 }
12995 else
12996 {
12997
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 26 times.
33 if(dmisc1)
12998 {
12999 7 flip=1;
13000 7 }
13001 }
13002
13003
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
13004 76 clk3=32;
13005 76 clk2=0;
13006 76 clk4=clk;
13007 76 dir=left;
13008 76 SIZEflags = d->SIZEflags;
13009
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13010 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13011 // al_trace("Enemy txsz:%i\n", txsz);
13012
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13014
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13016
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13017
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13018 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13019
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13021 {
13022 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13023 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13024 }
13025
13026
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13027 76 }
13028
13029 50824 bool eAquamentus::animate(int32_t index)
13030 {
13031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50824 times.
50824 if(switch_hooked) return enemy::animate(index);
13032
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 49558 times.
50824 if(dying)
13033 1266 return Dead(index);
13034
13035 // fbx=x+((id==eRAQUAM)?4:-4);
13036
2/2
✓ Branch 0 taken 49337 times.
✓ Branch 1 taken 221 times.
49558 if(clk==0)
13037 {
13038 221 removearmos(x,y,ffcactivated);
13039 221 }
13040
13041 49558 fbx=x;
13042
13043 /*
13044 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
13045 {
13046 fbx+=16;
13047 }
13048 */
13049
2/2
✓ Branch 0 taken 49241 times.
✓ Branch 1 taken 317 times.
49558 if(--clk3==0)
13050 {
13051 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
13052 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
13053 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
13054 317 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
13055 317 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
13056 317 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
13057 317 sfx(wpnsfx(wpn),pan(int32_t(x)));
13058 317 }
13059
13060
4/4
✓ Branch 0 taken 15161 times.
✓ Branch 1 taken 34397 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 14907 times.
49558 if(clk3<-80 && !(zc_oldrand()&63))
13061 {
13062 254 clk3=32;
13063 254 }
13064
13065
2/2
✓ Branch 0 taken 48766 times.
✓ Branch 1 taken 792 times.
49558 if(!((clk4+1)&63))
13066 {
13067 792 int32_t d2=(zc_oldrand()%3)+1;
13068
13069
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 533 times.
792 if(d2>=left)
13070 {
13071 533 dir=d2;
13072 533 }
13073
13074
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 442 times.
792 if(dmisc1)
13075 {
13076
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 35 times.
350 if(x<=40)
13077 {
13078 35 dir=right;
13079 35 }
13080
13081
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(x>=104)
13082 {
13083 dir=left;
13084 }
13085 350 }
13086 else
13087 {
13088
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 14 times.
442 if(x<=136)
13089 {
13090 14 dir=right;
13091 14 }
13092
13093
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 22 times.
442 if(x>=200)
13094 {
13095 22 dir=left;
13096 22 }
13097 }
13098 792 }
13099
13100
4/4
✓ Branch 0 taken 48440 times.
✓ Branch 1 taken 1118 times.
✓ Branch 2 taken 42352 times.
✓ Branch 3 taken 6088 times.
49558 if(clk4>=-1 && !((clk4+1)&7))
13101 {
13102
2/2
✓ Branch 0 taken 3226 times.
✓ Branch 1 taken 2862 times.
6088 if(dir==left)
13103 {
13104 3226 x-=1;
13105 3226 }
13106 else
13107 {
13108 2862 x+=1;
13109 }
13110 6088 }
13111
13112 49558 clk4=(clk4+1)%256;
13113
13114 49558 return enemy::animate(index);
13115 50824 }
13116
13117 51235 void eAquamentus::draw(BITMAP *dest)
13118 {
13119
2/2
✓ Branch 0 taken 29751 times.
✓ Branch 1 taken 21484 times.
51235 if(get_qr(qr_NEWENEMYTILES))
13120 {
13121 29751 xofs=(dmisc1?-16:0);
13122
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29751 times.
✓ Branch 2 taken 12244 times.
✓ Branch 3 taken 17507 times.
29751 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
13123
13124
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 29061 times.
29751 if(dying)
13125 {
13126 690 xofs=0;
13127 690 enemy::draw(dest);
13128 690 }
13129 else
13130 {
13131 29061 drawblock(dest,15);
13132 }
13133 29751 }
13134 else
13135 {
13136 21484 int32_t xblockofs=((dmisc1)?-16:16);
13137 21484 xofs=0;
13138
13139
4/4
✓ Branch 0 taken 20982 times.
✓ Branch 1 taken 502 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 20406 times.
21484 if(clk<0 || dying)
13140 {
13141 1078 enemy::draw(dest);
13142 1078 return;
13143 }
13144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20406 times.
20406 if ( do_animation )
13145 {
13146 // face (0=firing, 2=resting)
13147 20406 tile=o_tile+((clk3>0)?0:2);
13148 20406 enemy::draw(dest);
13149 // tail (
13150 20406 tile=o_tile+((clk&16)?1:3);
13151 20406 xofs=xblockofs;
13152 20406 enemy::draw(dest);
13153 // body
13154 20406 yofs+=16;
13155 20406 xofs=0;
13156 20406 tile=o_tile+((clk&16)?20:22);
13157 20406 enemy::draw(dest);
13158 20406 xofs=xblockofs;
13159 20406 tile=o_tile+((clk&16)?21:23);
13160 20406 enemy::draw(dest);
13161 20406 yofs-=16;
13162 20406 }
13163 else enemy::draw(dest);
13164 }
13165 51235 }
13166
13167 10639 bool eAquamentus::hit(weapon *w)
13168 {
13169
3/6
✓ Branch 0 taken 10639 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10639 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10639 times.
10639 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
13170
13171
2/2
✓ Branch 0 taken 2806 times.
✓ Branch 1 taken 7833 times.
10639 switch(w->id)
13172 {
13173 case wBeam:
13174 case wRefBeam:
13175 case wMagic:
13176 2806 hit_height=32;
13177 2806 }
13178
13179
4/4
✓ Branch 0 taken 10500 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 2202 times.
10639 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
13180 10639 hit_height=16;
13181 10639 return ret;
13182
13183 10639 }
13184
13185 55 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
13186 55 {
13187
13188
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( !(editorflags & ENEMY_FLAG5) )
13189 {
13190
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 x = 128;
13191
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 y = 48;
13192 55 }
13193 else { x = X; y = Y; }
13194
13195 55 Clk=Clk;
13196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(flags & guy_fadeflicker)
13197 {
13198 clk=0;
13199 superman = 1;
13200 fading=fade_flicker;
13201 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
13202 }
13203
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36 times.
55 else if(flags & guy_fadeinstant)
13204 {
13205 36 clk=0;
13206 36 }
13207 55 hxofs=-16;
13208 55 hit_width=48;
13209 55 clk4=0;
13210
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
13211
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 dir=zc_oldrand()%3+1;
13212 55 SIZEflags = d->SIZEflags;
13213
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13214 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13215 // al_trace("Enemy txsz:%i\n", txsz);
13216
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
13217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
13218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
13219
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
13220
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
13221
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
13222 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13223
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
13224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13225 {
13226 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
13227 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13228 }
13229
13230
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
13231
13232 //nets+5340;
13233 55 }
13234
13235 46569 bool eGohma::animate(int32_t index)
13236 {
13237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46569 times.
46569 if(switch_hooked) return enemy::animate(index);
13238
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 45799 times.
46569 if(dying)
13239 770 return Dead(index);
13240
13241
2/2
✓ Branch 0 taken 45788 times.
✓ Branch 1 taken 11 times.
45799 if(fading)
13242 {
13243
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(++clk4 > 60)
13244 {
13245 11 clk4=0;
13246 11 superman=0;
13247 11 fading=0;
13248 11 clk=0;
13249
13250 11 }
13251 else return enemy::animate(index);
13252 11 }
13253
13254
2/2
✓ Branch 0 taken 45583 times.
✓ Branch 1 taken 216 times.
45799 if(clk==0)
13255 {
13256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if (ffcactivated) removearmosffc(ffcactivated-1);
13257 else
13258 {
13259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 removearmos(zc_max(x-16, 0_zf),y);
13260 216 did_armos = false;
13261 216 removearmos(x,y);
13262 216 did_armos = false;
13263
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 removearmos(zc_min(x+16, 255_zf),y);
13264 }
13265 216 }
13266
13267
2/2
✓ Branch 0 taken 45511 times.
✓ Branch 1 taken 288 times.
45799 if(clk<0) return enemy::animate(index);
13268
13269 // Movement clk must be separate from animation clk because of the Clock item
13270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45511 times.
45511 if(!watch)
13271 45511 clk4++;
13272
13273
2/2
✓ Branch 0 taken 44826 times.
✓ Branch 1 taken 685 times.
45511 if((clk4&63)==0)
13274 {
13275
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 327 times.
685 if(clk4&64)
13276 358 dir^=1;
13277 else
13278 327 dir=zc_oldrand()%3+1;
13279 685 }
13280
13281
2/2
✓ Branch 0 taken 44776 times.
✓ Branch 1 taken 735 times.
45511 if((clk&63)==3)
13282 {
13283
2/2
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 187 times.
735 switch(dmisc1)
13284 {
13285 case 1:
13286 187 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
13287 187 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13288 187 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
13289 187 sfx(wpnsfx(wpn),pan(int32_t(x)));
13290 187 break;
13291
13292 default:
13293
3/4
✓ Branch 0 taken 548 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 463 times.
548 if(dmisc1 != 1 && dmisc1 != 2)
13294 {
13295 463 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13296 463 sfx(wpnsfx(wpn),pan(int32_t(x)));
13297 463 sfx(wpnsfx(wpn),pan(int32_t(x)));
13298 463 }
13299
13300 548 break;
13301 }
13302 735 }
13303
13304
6/6
✓ Branch 0 taken 5356 times.
✓ Branch 1 taken 40155 times.
✓ Branch 2 taken 5084 times.
✓ Branch 3 taken 272 times.
✓ Branch 4 taken 3692 times.
✓ Branch 5 taken 1392 times.
45511 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
13305 {
13306
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 1209 times.
1392 if(!(clk3%8))
13307 {
13308 183 FireBreath(true);
13309 183 }
13310 1392 }
13311
13312
2/2
✓ Branch 0 taken 22736 times.
✓ Branch 1 taken 22775 times.
45511 if(clk4&1)
13313 22775 move((zfix)1);
13314
13315
2/2
✓ Branch 0 taken 45411 times.
✓ Branch 1 taken 100 times.
45511 if(++clk3>=400)
13316 100 clk3=0;
13317
13318 45511 return enemy::animate(index);
13319 46569 }
13320
13321 46567 void eGohma::draw(BITMAP *dest)
13322 {
13323 46567 tile=o_tile;
13324
13325
4/4
✓ Branch 0 taken 46279 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 770 times.
✓ Branch 3 taken 45509 times.
46567 if(clk<0 || dying)
13326 {
13327 1058 enemy::drawzcboss(dest);
13328 1058 return;
13329 }
13330
13331
2/2
✓ Branch 0 taken 33176 times.
✓ Branch 1 taken 12333 times.
45509 if(get_qr(qr_NEWENEMYTILES))
13332 {
13333 ///if ( do_animation )
13334 //Yuck. Gohma can just not have this capability right now.
13335 // left side
13336 33176 xofs=-16;
13337 33176 flip=0;
13338 // if(clk&16) tile=180;
13339 // else { tile=182; flip=1; }
13340 33176 tile+=(3*((clk&48)>>4));
13341 33176 enemy::drawzcboss(dest);
13342
13343 // right side
13344 33176 xofs=16;
13345 // tile=(180+182)-tile;
13346 33176 tile=o_tile;
13347 33176 tile+=(3*((clk&48)>>4))+2;
13348 33176 enemy::drawzcboss(dest);
13349
13350 // body
13351 33176 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
13352 33176 tile=o_tile;
13353
13354 // tile+=(3*((clk&24)>>3))+2;
13355
2/2
✓ Branch 0 taken 1759 times.
✓ Branch 1 taken 31417 times.
33176 if(clk3<16)
13356 1759 tile+=7;
13357
2/2
✓ Branch 0 taken 9419 times.
✓ Branch 1 taken 21998 times.
31417 else if(clk3<116)
13358 9419 tile+=10;
13359
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 20683 times.
21998 else if(clk3<132)
13360 1315 tile+=7;
13361 else
13362 20683 tile+=((clk3-132)&24)?4:1;
13363
13364 33176 enemy::drawzcboss(dest);
13365
13366 33176 }
13367 else
13368 {
13369 // left side
13370 12333 xofs=-16;
13371 12333 flip=0;
13372
13373
2/2
✓ Branch 0 taken 6107 times.
✓ Branch 1 taken 6226 times.
12333 if(!(clk&16))
13374 {
13375 6226 tile+=2;
13376 6226 flip=1;
13377 6226 }
13378
13379 12333 enemy::draw(dest);
13380
13381 // right side
13382 12333 tile=o_tile;
13383 12333 xofs=16;
13384
13385
2/2
✓ Branch 0 taken 6226 times.
✓ Branch 1 taken 6107 times.
12333 if((clk&16)) tile+=2;
13386
13387 // tile=(180+182)-tile;
13388 12333 enemy::draw(dest);
13389
13390 // body
13391 12333 tile=o_tile;
13392 12333 xofs=0;
13393
13394
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 11613 times.
12333 if(clk3<16)
13395 720 tile+=4;
13396
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 7729 times.
11613 else if(clk3<116)
13397 3884 tile+=5;
13398
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 7256 times.
7729 else if(clk3<132)
13399 473 tile+=4;
13400 7256 else tile+=((clk3-132)&8)?3:1;
13401
13402 12333 enemy::draw(dest);
13403
13404 }
13405 46567 }
13406
13407 230 int32_t eGohma::takehit(weapon *w, weapon* realweap)
13408 {
13409 230 int32_t wpnId = w->id;
13410 230 int32_t power = w->power;
13411 230 int32_t wpnx = w->x;
13412 230 int32_t wpnDir = w->dir;
13413 230 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
13414
13415
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 108 times.
230 if(def < 0)
13416 {
13417
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 67 times.
✓ Branch 9 taken 13 times.
108 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
13418 {
13419 41 sfx(WAV_CHINK,pan(int32_t(x)));
13420 41 return 1;
13421 }
13422 67 }
13423
13424 189 return enemy::takehit(w, realweap);
13425 230 }
13426
13427 198 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13428 198 {
13429 198 count_enemy=(id==(id&0xFFF));
13430 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13431 198 SIZEflags = d->SIZEflags;
13432
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13433 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13434 // al_trace("Enemy txsz:%i\n", txsz);
13435
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13436
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13437
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13438
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13439
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13440
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13441 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13442
1/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13444 {
13445 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13446 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13447 }
13448
13449
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13450 198 }
13451
13452 75067 bool eLilDig::animate(int32_t index)
13453 {
13454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75067 times.
75067 if(switch_hooked) return enemy::animate(index);
13455
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 72061 times.
75067 if(dying)
13456 3006 return Dead(index);
13457
13458
2/2
✓ Branch 0 taken 4113 times.
✓ Branch 1 taken 67948 times.
72061 if(clk==0)
13459 {
13460 4113 removearmos(x,y,ffcactivated);
13461 4113 }
13462
13463
2/2
✓ Branch 0 taken 48439 times.
✓ Branch 1 taken 23622 times.
72061 if(misc<=128)
13464 {
13465
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 22911 times.
23622 if(!(++misc&31))
13466 711 step+=0.25;
13467 23622 }
13468
13469 72061 variable_walk_8(rate,homing,hrate,spw_floater);
13470 72061 return enemy::animate(index);
13471 75067 }
13472
13473 74914 void eLilDig::draw(BITMAP *dest)
13474 {
13475 74914 tile = o_tile;
13476 // tile = 160;
13477 74914 int32_t fdiv = frate/4;
13478
1/2
✓ Branch 0 taken 74914 times.
✗ Branch 1 not taken.
74914 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13479
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13480 74914 efrate:((clk>=(frate>>1))?1:0);
13481
13482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74914 times.
74914 if ( do_animation )
13483 {
13484
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 if(get_qr(qr_NEWENEMYTILES))
13485 {
13486
9/9
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 5465 times.
✓ Branch 2 taken 5245 times.
✓ Branch 3 taken 5717 times.
✓ Branch 4 taken 5242 times.
✓ Branch 5 taken 4505 times.
✓ Branch 6 taken 3937 times.
✓ Branch 7 taken 5312 times.
✓ Branch 8 taken 5035 times.
46311 switch(dir-8) //directions get screwed up after 8. *shrug*
13487 {
13488 case up: //u
13489 5853 flip=0;
13490 5853 break;
13491
13492 case l_up: //d
13493 5465 flip=0;
13494 5465 tile+=4;
13495 5465 break;
13496
13497 case l_down: //l
13498 5245 flip=0;
13499 5245 tile+=8;
13500 5245 break;
13501
13502 case left: //r
13503 5717 flip=0;
13504 5717 tile+=12;
13505 5717 break;
13506
13507 case r_down: //ul
13508 5242 flip=0;
13509 5242 tile+=20;
13510 5242 break;
13511
13512 case down: //ur
13513 4505 flip=0;
13514 4505 tile+=24;
13515 4505 break;
13516
13517 case r_up: //dl
13518 3937 flip=0;
13519 3937 tile+=28;
13520 3937 break;
13521
13522 case right: //dr
13523 5035 flip=0;
13524 5035 tile+=32;
13525 5035 break;
13526 }
13527
13528 46311 tile+=f2;
13529 46311 }
13530 else
13531 {
13532 28603 tile+=(clk>=6)?1:0;
13533 }
13534 74914 }
13535
13536 74914 enemy::draw(dest);
13537 74914 }
13538
13539 52 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13540 52 {
13541 52 superman=1;
13542
13543 52 SIZEflags = d->SIZEflags;
13544
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13545 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13546 // al_trace("Enemy txsz:%i\n", txsz);
13547
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13549 52 else hit_width=32;
13550
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13551 52 else hit_height=32;
13552
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13553 52 else hzsz=16; // hard to jump.
13554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13555 52 else hxofs=-8;
13556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13557 52 else hyofs=-8;
13558 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13559
1/4
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13561 {
13562 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13563 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13564 }
13565
13566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13567
13568
13569 52 }
13570
13571 22457 bool eBigDig::animate(int32_t index)
13572 {
13573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(switch_hooked) return enemy::animate(index);
13574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(dying)
13575 return Dead(index);
13576
13577
2/2
✓ Branch 0 taken 19263 times.
✓ Branch 1 taken 3194 times.
22457 if(clk==0)
13578 {
13579 3194 removearmos(x,y,ffcactivated);
13580 3194 }
13581
13582
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22369 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 44 times.
22457 switch(misc)
13583 {
13584 case 0:
13585 22369 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13586 22369 break;
13587
13588 case 1:
13589 44 ++misc;
13590 44 break;
13591
13592 case 2:
13593
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 44 times.
149 for(int32_t i=0; i<dmisc5; i++)
13594 {
13595 105 addenemy(x,y,dmisc1+0x1000,-15);
13596 105 }
13597
13598
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc6; i++)
13599 {
13600 16 addenemy(x,y,dmisc2+0x1000,-15);
13601 16 }
13602
13603
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc7; i++)
13604 {
13605 16 addenemy(x,y,dmisc3+0x1000,-15);
13606 16 }
13607
13608
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc8; i++)
13609 {
13610 16 addenemy(x,y,dmisc4+0x1000,-15);
13611 16 }
13612
13613
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 1 times.
44 if(itemguy) // Hand down the carried item
13614 {
13615 1 guycarryingitem = guys.Count()-1;
13616 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13617 1 itemguy = false;
13618 1 }
13619
13620 44 stop_bgsfx(index);
13621
13622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13623
13624 44 return true;
13625 }
13626
13627 22413 return enemy::animate(index);
13628 22457 }
13629
13630 22452 void eBigDig::draw(BITMAP *dest)
13631 {
13632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if(anim!=aDIG)
13633 {
13634 update_enemy_frame();
13635 xofs-=8;
13636 yofs-=8;
13637 drawblock(dest,15);
13638 xofs+=8;
13639 yofs+=8;
13640 return;
13641 }
13642
13643 22452 tile = o_tile;
13644 22452 int32_t fdiv = frate/4;
13645
1/2
✓ Branch 0 taken 22452 times.
✗ Branch 1 not taken.
22452 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13646
13647
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13648 22452 efrate:((clk>=(frate>>1))?1:0);
13649
13650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if ( do_animation )
13651 {
13652
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 if(get_qr(qr_NEWENEMYTILES))
13653 {
13654
9/9
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 1195 times.
✓ Branch 4 taken 1233 times.
✓ Branch 5 taken 1223 times.
✓ Branch 6 taken 993 times.
✓ Branch 7 taken 1450 times.
✓ Branch 8 taken 464 times.
10238 switch(dir-8) //directions get screwed up after 8. *shrug*
13655 {
13656 case up: //u
13657 1115 flip=0;
13658 1115 break;
13659
13660 case l_up: //d
13661 1221 flip=0;
13662 1221 tile+=8;
13663 1221 break;
13664
13665 case l_down: //l
13666 1344 flip=0;
13667 1344 tile+=40;
13668 1344 break;
13669
13670 case left: //r
13671 1195 flip=0;
13672 1195 tile+=48;
13673 1195 break;
13674
13675 case r_down: //ul
13676 1233 flip=0;
13677 1233 tile+=80;
13678 1233 break;
13679
13680 case down: //ur
13681 1223 flip=0;
13682 1223 tile+=88;
13683
13684 1223 break;
13685
13686 case r_up: //dl
13687 993 flip=0;
13688 993 tile+=120;
13689 993 break;
13690
13691 case right: //dr
13692 1450 flip=0;
13693 1450 tile+=128;
13694 1450 break;
13695 }
13696
13697 10238 tile+=(f2*2);
13698 10238 }
13699 else
13700 {
13701 12214 tile+=(f2)?0:2;
13702 12214 flip=(clk&1)?1:0;
13703 }
13704 22452 }
13705
13706 22452 xofs-=8;
13707 22452 yofs-=8;
13708 22452 drawblock(dest,15);
13709 22452 xofs+=8;
13710 22452 yofs+=8;
13711 22452 }
13712
13713 740 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13714 {
13715 740 int32_t wpnId = w->id;
13716
13717
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
740 if(wpnId==wWhistle && misc==0)
13718 44 misc=1;
13719
13720 740 return 0;
13721 }
13722
13723 /*
13724 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13725 {
13726 hxofs=hyofs=8;
13727 hzsz=16; //can't be jumped.
13728 clk2=70;
13729 misc=-1;
13730 mainguy=!getmapflag();
13731 }
13732
13733 bool eGanon::animate(int32_t index)
13734 {
13735 if(switch_hooked) return enemy::animate(index);
13736 if(dying)
13737
13738 return Dead(index);
13739
13740 if(clk==0)
13741 {
13742 removearmos(x,y,ffcactivated);
13743 }
13744
13745 switch(misc)
13746 {
13747 case -1:
13748 misc=0;
13749
13750 case 0:
13751 if(++clk2>72 && !(zc_oldrand()&3))
13752 {
13753 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
13754 sfx(wpnsfx(wpn),pan(int32_t(x)));
13755 clk2=0;
13756 }
13757
13758 Stunclk=0;
13759 constant_walk(rate,homing,spw_none);
13760 break;
13761
13762 case 1:
13763 case 2:
13764 if(--Stunclk<=0)
13765 {
13766 int32_t r=zc_oldrand();
13767
13768 if(r&1)
13769 {
13770 y=96;
13771
13772 if(r&2)
13773 x=160;
13774 else
13775 x=48;
13776
13777 if(tooclose(x,y,48))
13778 x=208-x;
13779 }
13780
13781 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
13782 //{
13783 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13784 // }
13785 // else
13786 // {
13787 loadpalset(csBOSS,pSprite(d->bosspal));
13788 // }
13789 misc=0;
13790 }
13791
13792 break;
13793
13794 case 3:
13795 {
13796 if(hclk>0)
13797 break;
13798
13799 misc=4;
13800 clk=0;
13801 hxofs=1000;
13802 loadpalset(9,pSprite(spPILE));
13803 music_stop();
13804 stop_sfx(WAV_ROAR);
13805
13806 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13807
13808 sfx(WAV_GANON);
13809 //Ganon's dustpile; fall in sideview. -Z
13810 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13811 dustpile->linked_parent = eeGANON;
13812 setmapflag();
13813 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13814 break;
13815 }
13816
13817 case 4:
13818 if(clk>=80)
13819 {
13820 misc=5;
13821
13822 if(getmapflag())
13823 {
13824 game->lvlitems[dlevel]|=liBOSS;
13825 //play_DmapMusic();
13826 playLevelMusic();
13827 return true;
13828 }
13829
13830 sfx(WAV_CLEARED);
13831 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
13832 setmapflag();
13833 }
13834
13835 break;
13836 }
13837
13838 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
13839 //{
13840 //if ( current_item_id(itype_amulet,false) >= 2 )
13841 //{
13842 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13843 //}
13844 //}
13845
13846
13847 return enemy::animate(index);
13848 }
13849
13850
13851 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13852 {
13853 //these are here to bypass compiler warnings about unused arguments
13854 int32_t wpnId = w->id;
13855 int32_t power = w->power;
13856 int32_t enemyHitWeapon = w->parentitem;
13857
13858 switch(misc)
13859 {
13860 case 0:
13861 {
13862 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
13863 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
13864 return 0;
13865
13866 //if we are not using the new defences, just reduce his HP
13867 if (!(editorflags & ENEMY_FLAG14))
13868 {
13869 hp-=power;
13870 if(hp>0)
13871 {
13872 misc=1;
13873 Stunclk=64;
13874 }
13875 else
13876 {
13877 loadpalset(csBOSS,pSprite(spBROWN));
13878 misc=2;
13879 Stunclk=284;
13880 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13881 }
13882
13883 sfx(WAV_EHIT,pan(int32_t(x)));
13884
13885 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13886
13887 return 1;
13888 }
13889 //otherwise, resolve his defence.
13890 else
13891 {
13892 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
13893 if(hp>0)
13894 {
13895 misc=1;
13896 Stunclk=64;
13897 }
13898 else
13899 {
13900 loadpalset(csBOSS,pSprite(spBROWN));
13901 misc=2;
13902 Stunclk=284;
13903 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13904 }
13905
13906 sfx(WAV_EHIT,pan(int32_t(x)));
13907
13908 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13909
13910
13911 return 1;
13912 }
13913 }
13914 case 2:
13915 {
13916 if
13917 (
13918 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
13919 || //or nothing specified, use silver arrows+
13920 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
13921 )
13922 return 0;
13923 {
13924 misc=3;
13925 hclk=81;
13926 loadpalset(9,pSprite(spBROWN));
13927 return 1;
13928 }
13929
13930 }
13931 }
13932
13933 return 0;
13934 }
13935
13936 void eGanon::draw(BITMAP *dest)
13937 {
13938 switch(misc)
13939 {
13940 case 0:
13941 if((clk&3)==3)
13942 tile=(zc_oldrand()%5)*2+o_tile;
13943
13944 if(db!=999)
13945 break;
13946
13947 case 2:
13948 if(Stunclk<64 && (Stunclk&1) )
13949 {
13950 if
13951 (
13952 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13953 ||
13954 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13955 )
13956 {
13957 goto ganon_draw; //draw his weapons if we can see him
13958 }
13959 break;
13960 }
13961
13962 case -1:
13963 tile=o_tile;
13964
13965 //fall through
13966 case 1:
13967 case 3:
13968 ganon_draw:
13969 drawblock(dest,15);
13970 break;
13971
13972 case 4:
13973 draw_guts(dest);
13974 draw_flash(dest);
13975 break;
13976 }
13977
13978 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
13979 {
13980 if
13981 (
13982 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13983 ||
13984 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13985 )
13986 {
13987 draw_guts(dest); //makes his shots visible, but not him
13988 draw_flash(dest);
13989 }
13990 }
13991 }
13992
13993 void eGanon::draw_guts(BITMAP *dest)
13994 {
13995 int32_t c = zc_min(clk>>3,8);
13996 tile = clk<24 ? 74 : 75;
13997 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13998 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13999 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
14000 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
14001 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
14002 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
14003 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
14004 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
14005 }
14006
14007 void eGanon::draw_flash(BITMAP *dest)
14008 {
14009
14010 int32_t c = clk-(clk>>2);
14011 cs = (frame&3)+6;
14012 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14013 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14014 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14015 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14016 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14017 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14018 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14019 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14020 }
14021 */
14022
14023 10 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14024 10 {
14025 10 hxofs=hyofs=8;
14026
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (editorflags & ENEMY_FLAG3)
14027 {
14028 hxofs = 4;
14029 hyofs = 4;
14030 hit_width = 24;
14031 hit_height = 24;
14032 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
14033 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
14034 }
14035 10 hzsz=16; //can't be jumped.
14036 10 clk2=70;
14037 10 misc=-1;
14038
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
14039 10 }
14040
14041 15877 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
14042 {
14043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15877 times.
15877 if(dying)
14044
14045 return Dead(index);
14046
14047
2/2
✓ Branch 0 taken 15814 times.
✓ Branch 1 taken 63 times.
15877 if(clk==0)
14048 {
14049 63 removearmos(x,y,ffcactivated);
14050 63 }
14051
14052
6/7
✓ Branch 0 taken 2935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11467 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 738 times.
✓ Branch 5 taken 720 times.
✓ Branch 6 taken 7 times.
15877 switch(misc)
14053 {
14054 case -1:
14055 10 misc=0;
14056 [[fallthrough]];
14057 case 0:
14058
4/4
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 10850 times.
✓ Branch 2 taken 471 times.
✓ Branch 3 taken 156 times.
11477 if(++clk2>72 && !(zc_oldrand()&3))
14059 {
14060 156 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14061 156 sfx(wpnsfx(wpn),pan(int32_t(x)));
14062 156 clk2=0;
14063 156 }
14064
14065 11477 Stunclk=0;
14066 11477 constant_walk(rate,homing,spw_none);
14067 11477 break;
14068
14069 case 1:
14070 case 2:
14071
2/2
✓ Branch 0 taken 2901 times.
✓ Branch 1 taken 34 times.
2935 if(--Stunclk<=0)
14072 {
14073 34 int32_t r=zc_oldrand();
14074
14075
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 14 times.
34 if(r&1)
14076 {
14077 14 y=96;
14078
14079
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8 times.
14 if(r&2)
14080 6 x=160;
14081 else
14082 8 x=48;
14083
14084
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
14 if(tooclose(x,y,48))
14085 6 x=208-x;
14086 14 }
14087
14088 34 loadpalset(csBOSS,pSprite(d->bosspal));
14089 34 misc=0;
14090 34 }
14091
14092 2935 break;
14093
14094 case 3:
14095 {
14096
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 9 times.
738 if(hclk>0)
14097 729 break;
14098
14099 9 misc=4;
14100 9 clk=0;
14101 9 hxofs=1000;
14102 9 loadpalset(9,pSprite(spPILE));
14103 9 music_stop();
14104 9 stop_sfx(WAV_ROAR);
14105
14106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
14107
14108 9 sfx(WAV_GANON);
14109 //Ganon's dustpile; fall in sideview. -Z
14110 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
14111 //dustpile->miscellaneous[31] = eeGANON;
14112
6/12
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
9 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14113 9 item *dustpile = NULL;
14114 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
14115 9 dustpile = (item *)items.spr(items.Count() - 1);
14116 9 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
14117 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
14118 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14119 9 break;
14120 }
14121
14122 case 4:
14123
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 9 times.
720 if(clk>=80)
14124 {
14125 9 misc=5;
14126
14127 //game->lvlitems[dlevel]|=liBOSS;
14128
14129 9 sfx(WAV_CLEARED);
14130 //Add the big TF over the ashes!
14131
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
27 for(word q = 0; q < items.Count(); q++)
14132 {
14133 18 item *ashes = (item*)items.spr(q);
14134
3/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
18 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
14135 {
14136 //Z_scripterrlog("Found correct dustpile!\n");
14137
4/8
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
9 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
14138 9 item *bigtriforce = NULL;
14139 9 bigtriforce = (item *)items.spr(items.Count() - 1);
14140 9 bigtriforce->linked_parent = eeGANON;
14141 9 }
14142 18 }
14143 //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14144 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
14145 9 }
14146
14147 720 break;
14148 7 case 5: return true;
14149 }
14150
14151 15870 return enemy::animate(index);
14152 15877 }
14153
14154
14155 803 int32_t eGanon::takehit(weapon *w, weapon* realweap)
14156 {
14157 //these are here to bypass compiler warnings about unused arguments
14158 803 int32_t wpnId = w->id;
14159 803 int32_t power = w->power;
14160 803 int32_t enemyHitWeapon = w->parentitem;
14161
14162
3/3
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 125 times.
803 switch(misc)
14163 {
14164 case 0:
14165
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 43 times.
74 if(wpnId!=wSword)
14166 31 return 0;
14167
14168 43 hp-=power;
14169
14170
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 9 times.
43 if(hp>0)
14171 {
14172 34 misc=1;
14173 34 Stunclk=64;
14174 34 }
14175 else
14176 {
14177 9 loadpalset(csBOSS,pSprite(spBROWN));
14178 9 misc=2;
14179 9 Stunclk=284;
14180 9 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
14181 }
14182
14183 43 sfx(WAV_EHIT,pan(int32_t(x)));
14184
14185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
14186
14187 43 return 1;
14188
14189 case 2:
14190
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
125 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
14191 116 return 0;
14192
14193 9 misc=3;
14194 9 hclk=81;
14195 9 loadpalset(9,pSprite(spBROWN));
14196 9 return 1;
14197 }
14198
14199 604 return 0;
14200 803 }
14201
14202 17817 void eGanon::draw(BITMAP *dest)
14203 {
14204
6/6
✓ Branch 0 taken 2914 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 759 times.
✓ Branch 3 taken 1950 times.
✓ Branch 4 taken 11467 times.
✓ Branch 5 taken 720 times.
17817 switch(misc)
14205 {
14206 case 0:
14207
2/2
✓ Branch 0 taken 8601 times.
✓ Branch 1 taken 2866 times.
11467 if((clk&3)==3)
14208 2866 tile=(zc_oldrand()%5)*2+o_tile;
14209
14210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11467 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
14211 {
14212
14213 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14214 {
14215 int odraw = drawstyle;
14216 drawstyle = 2;
14217 drawblock(dest,15);
14218 drawstyle = odraw;
14219 }
14220 else
14221 {
14222 drawblock(dest,15);
14223 }
14224 break;
14225
14226 }
14227
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11467 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
14228 {
14229 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14230 {
14231 int odraw = drawstyle;
14232 drawstyle = 2;
14233 drawblock(dest,15);
14234 drawstyle = odraw;
14235 }
14236 else
14237 {
14238 drawblock(dest,15);
14239 }
14240 break;
14241 }
14242
1/2
✓ Branch 0 taken 11467 times.
✗ Branch 1 not taken.
11467 if(db!=999)
14243 11467 break;
14244 [[fallthrough]];
14245 case 2:
14246
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
759 if(Stunclk<64 && (Stunclk&1))
14247 break;
14248 [[fallthrough]];
14249 case -1:
14250 2709 tile=o_tile;
14251
14252 [[fallthrough]];
14253 case 1:
14254 case 3:
14255 5623 drawblock(dest,15);
14256 5623 break;
14257
14258 case 4:
14259 720 draw_guts(dest);
14260 720 draw_flash(dest);
14261 720 break;
14262 }
14263 17817 }
14264
14265 720 void eGanon::draw_guts(BITMAP *dest)
14266 {
14267
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 153 times.
720 int32_t c = zc_min(clk>>3,8);
14268 720 tile = clk<24 ? 74 : 75;
14269 720 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
14270 720 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
14271 720 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
14272 720 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
14273 720 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
14274 720 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
14275 720 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
14276 720 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
14277 720 }
14278
14279 720 void eGanon::draw_flash(BITMAP *dest)
14280 {
14281
14282 720 int32_t c = clk-(clk>>2);
14283 720 cs = (frame&3)+6;
14284 720 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14285 720 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14286 720 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14287 720 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14288 720 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14289 720 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14290 720 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14291 720 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14292 720 }
14293
14294 8 void getBigTri(int32_t id2)
14295 {
14296 /*
14297 *************************
14298 * BIG TRIFORCE SEQUENCE *
14299 *************************
14300 0 BIGTRI out, WHITE flash in
14301 4 WHITE flash out, PILE cset white
14302 8 WHITE in
14303 ...
14304 188 WHITE out
14305 191 PILE cset red
14306 200 top SHUTTER opens
14307 209 bottom SHUTTER opens
14308 */
14309 8 sfx(itemsbuf[id2].playsound);
14310 8 guys.clear();
14311
14312
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
14313 {
14314 game->lvlitems[dlevel]|=liTRIFORCE;
14315 }
14316
14317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14318
14319 8 draw_screen(tmpscr);
14320
14321
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 1536 times.
1544 for(int32_t f=0; f<24*8 && !Quit; f++)
14322 {
14323
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 8 times.
1536 if(f==4)
14324 {
14325
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 8 times.
128 for(int32_t i=1; i<16; i++)
14326 {
14327 120 RAMpal[CSET(9)+i]=_RGB(63,63,63);
14328 120 }
14329 8 }
14330
14331
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 192 times.
1536 if((f&7)==0)
14332 {
14333
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 for(int32_t cs=2; cs<5; cs++)
14334 {
14335
2/2
✓ Branch 0 taken 8640 times.
✓ Branch 1 taken 576 times.
9216 for(int32_t i=1; i<16; i++)
14336 {
14337 8640 RAMpal[CSET(cs)+i]=_RGB(63,63,63);
14338 8640 }
14339 576 }
14340
14341 192 refreshpal=true;
14342 192 }
14343
14344
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 192 times.
1536 if((f&7)==4)
14345 {
14346
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
14347 else loadlvlpal(0xB);
14348 192 }
14349
14350
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 8 times.
1536 if(f==191)
14351 {
14352 8 loadpalset(9,pSprite(spPILE));
14353 8 }
14354
14355 1536 advanceframe(true);
14356 1536 }
14357
14358 //play_DmapMusic();
14359 8 playLevelMusic();
14360
14361
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128)
14362 {
14363 Hero.dowarp(1,0); //side warp
14364 }
14365 8 }
14366
14367 /**********************************/
14368 /*** Multiple-Segment Enemies ***/
14369 /**********************************/
14370
14371
14372 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
14373 94 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14374 94 {
14375
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if( !(editorflags & ENEMY_FLAG5) )
14376 {
14377
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 x=128;
14378
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 y=48;
14379 94 }
14380 //else { x = X; y = Y; }
14381
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 dir=(zc_oldrand()&7)+8;
14382 94 superman=1;
14383 94 fading=fade_invisible;
14384 94 hxofs=1000;
14385 94 segcnt=clk;
14386 94 segid=Id|0x1000;
14387 94 clk=0;
14388
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 id=guys.Count();
14389
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
94 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14390 94 tile=o_tile;
14391 94 hitdir = -1;
14392 94 stickclk = 0;
14393
14394 /*
14395 if (get_qr(qr_NEWENEMYTILES))
14396 {
14397 tile=nets+1220;
14398 }
14399 else
14400 {
14401 tile=57;
14402 }
14403 */
14404 94 }
14405
14406 86130 bool eMoldorm::animate(int32_t index)
14407 {
14408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86130 times.
86130 if(switch_hooked) return enemy::animate(index);
14409 86130 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
14410
2/2
✓ Branch 0 taken 66843 times.
✓ Branch 1 taken 19287 times.
86130 if ( y > (max_y) )
14411 {
14412 19287 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
14413 //Z_scripterrlog("Stickclk is %d\n", stickclk);
14414 19287 }
14415
2/2
✓ Branch 0 taken 85736 times.
✓ Branch 1 taken 394 times.
86130 if ( stickclk > 45 )
14416 {
14417 394 stickclk = 0;
14418 394 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
14419 394 }
14420
14421
14422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86130 times.
86130 if(clk==0)
14423 {
14424 86130 removearmos(x,y,ffcactivated);
14425 86130 }
14426
14427
2/2
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 84876 times.
86130 if(clk2)
14428 {
14429
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 66 times.
1254 if(--clk2 == 0)
14430 {
14431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(flags&guy_neverret)
14432 66 never_return(index);
14433
14434
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
14435 66 leave_item();
14436
14437 66 stop_bgsfx(index);
14438 66 return true;
14439 }
14440 1188 }
14441 else
14442 {
14443
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if(stunclk>0)
14444 stunclk=0;
14445 84876 constant_walk_8_old(rate,homing,spw_floater);
14446
14447
14448 84876 misc=dir;
14449
14450 // If any higher-numbered segments were killed, segcnt can be too high,
14451 // leading to a crash
14452
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if(index+segcnt>=guys.Count())
14453 segcnt=guys.Count()-index-1;
14454
14455
2/2
✓ Branch 0 taken 84876 times.
✓ Branch 1 taken 453901 times.
538777 for(int32_t i=index+1; i<index+segcnt+1; i++)
14456 {
14457 453901 enemy* segment=((enemy*)guys.spr(i));
14458
14459 // More validation - if segcnt was wrong, this may not
14460 // actually be a Moldorm segment
14461
1/2
✓ Branch 0 taken 453901 times.
✗ Branch 1 not taken.
453901 if(segment->id!=segid)
14462 {
14463 segcnt=i-index-1;
14464 break;
14465 }
14466
14467
2/2
✓ Branch 0 taken 368935 times.
✓ Branch 1 taken 84966 times.
453901 if(i==index+1)
14468 {
14469 84966 x=segment->x;
14470 84966 y=segment->y;
14471 84966 }
14472
14473 453901 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
14474 //Script your own blasted segmented bosses!! -Z
14475 453901 segment->parent_script_UID = this->script_UID;
14476
4/4
✓ Branch 0 taken 84876 times.
✓ Branch 1 taken 369025 times.
✓ Branch 2 taken 12139 times.
✓ Branch 3 taken 72737 times.
453901 if((i==index+segcnt)&&(i!=index+1)) //tail
14477 {
14478 72737 segment->dummy_int[1]=2;
14479 72737 }
14480 else
14481 {
14482 381164 segment->dummy_int[1]=1;
14483 }
14484
14485
2/2
✓ Branch 0 taken 368935 times.
✓ Branch 1 taken 84966 times.
453901 if(i==index+1) //head
14486 {
14487 84966 segment->dummy_int[1]=0;
14488 84966 }
14489
14490
2/2
✓ Branch 0 taken 453501 times.
✓ Branch 1 taken 400 times.
453901 if(segment->hp <= 0)
14491 {
14492 400 int32_t offset=1;
14493
14494
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 618 times.
1018 for(int32_t j=i; j<index+segcnt; j++)
14495 {
14496 // Triple-check
14497
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if(((enemy*)guys.spr(j+1))->id!=segid)
14498 {
14499 segcnt=j-index+1; // Add 1 because of --segcnt below
14500 break;
14501 }
14502 618 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14503 618 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14504 618 }
14505
14506 400 segment->hclk=33;
14507 400 --segcnt;
14508 400 --i; // Recheck the same index in case multiple segments died at once
14509 400 }
14510 453901 }
14511
14512
2/2
✓ Branch 0 taken 84810 times.
✓ Branch 1 taken 66 times.
84876 if(segcnt==0)
14513 {
14514 66 clk2=19;
14515
14516 66 x=guys.spr(index+1)->x;
14517 66 y=guys.spr(index+1)->y;
14518 66 }
14519 }
14520
14521 86064 return false;
14522 86130 }
14523
14524 530 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14525 530 {
14526
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 if( !(editorflags & ENEMY_FLAG5) )
14527 {
14528
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 x=128;
14529
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 y=48;
14530 530 }
14531
14532
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 530 times.
✓ Branch 2 taken 530 times.
✗ Branch 3 not taken.
530 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14533 530 hyofs=4;
14534 530 hit_width=hit_height=8;
14535 530 hxofs=1000;
14536 530 mainguy=count_enemy=false;
14537 530 parentclk = 0;
14538 530 bgsfx=-1;
14539 530 flags&=~guy_neverret;
14540 //deadsfx = WAV_EDEAD;
14541 530 isCore = false;
14542 530 }
14543
14544 460921 bool esMoldorm::animate(int32_t index)
14545 {
14546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460921 times.
460921 if(switch_hooked) return enemy::animate(index);
14547 // Shouldn't be possible, but better to be sure
14548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460921 times.
460921 if(index==0)
14549 dying=true;
14550
14551
2/2
✓ Branch 0 taken 7020 times.
✓ Branch 1 taken 453901 times.
460921 if(dying)
14552 {
14553
1/2
✓ Branch 0 taken 7020 times.
✗ Branch 1 not taken.
7020 if(!dmisc2)
14554 7020 item_set=0;
14555
14556 7020 return Dead(index);
14557 }
14558
14559
2/2
✓ Branch 0 taken 22038 times.
✓ Branch 1 taken 431863 times.
453901 if(clk>=0)
14560 {
14561 431863 hxofs=4;
14562 431863 step=((enemy*)guys.spr(index-1))->step;
14563
14564
2/2
✓ Branch 0 taken 32657 times.
✓ Branch 1 taken 399206 times.
431863 if(parentclk == 0)
14565 {
14566 32657 misc=dir;
14567 32657 dir=((enemy*)guys.spr(index-1))->misc;
14568 //do alignment, as in parent's animation :-/ -DD
14569 32657 x.doFloor();
14570 32657 y.doFloor();
14571 32657 }
14572
14573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431863 times.
431863 if(step)
14574 431863 parentclk=(parentclk+1)%((int32_t)(8.0/step));
14575
14576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431863 times.
431863 if(!watch)
14577 {
14578 431863 sprite::move(step);
14579 431863 }
14580 431863 }
14581
14582 453901 return enemy::animate(index);
14583 460921 }
14584
14585 1735 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
14586 {
14587
2/2
✓ Branch 0 taken 1588 times.
✓ Branch 1 taken 147 times.
1735 if(enemy::takehit(w,realweap))
14588 1588 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14589
14590 147 return 0;
14591 1735 }
14592
14593 462871 void esMoldorm::draw(BITMAP *dest)
14594 {
14595 462871 tile=o_tile;
14596 462871 int32_t fdiv = frate/4;
14597
1/2
✓ Branch 0 taken 462871 times.
✗ Branch 1 not taken.
462871 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14598
14599
2/2
✓ Branch 0 taken 385733 times.
✓ Branch 1 taken 77138 times.
462871 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14600 462871 efrate:((clk>=(frate>>1))?1:0);
14601
14602
2/2
✓ Branch 0 taken 77138 times.
✓ Branch 1 taken 385733 times.
462871 if(get_qr(qr_NEWENEMYTILES))
14603 {
14604 385733 tile+=dummy_int[1]*40;
14605
14606
2/2
✓ Branch 0 taken 17795 times.
✓ Branch 1 taken 367938 times.
385733 if(dir<8)
14607 {
14608 17795 flip=0;
14609
1/2
✓ Branch 0 taken 17795 times.
✗ Branch 1 not taken.
17795 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
14610
14611
1/2
✓ Branch 0 taken 17795 times.
✗ Branch 1 not taken.
17795 if(dir>3) // Skip to the next row for diagonals
14612 tile+=4;
14613 17795 }
14614 else
14615 {
14616
8/9
✓ Branch 0 taken 40703 times.
✓ Branch 1 taken 50522 times.
✓ Branch 2 taken 41128 times.
✓ Branch 3 taken 50152 times.
✓ Branch 4 taken 42370 times.
✓ Branch 5 taken 40742 times.
✓ Branch 6 taken 49191 times.
✓ Branch 7 taken 53130 times.
✗ Branch 8 not taken.
367938 switch(dir-8) //directions get screwed up after 8. *shrug*
14617 {
14618 case up: //u
14619 40703 flip=0;
14620 40703 break;
14621
14622 case l_up: //d
14623 50522 flip=0;
14624 50522 tile+=4;
14625 50522 break;
14626
14627 case l_down: //l
14628 41128 flip=0;
14629 41128 tile+=8;
14630 41128 break;
14631
14632 case left: //r
14633 50152 flip=0;
14634 50152 tile+=12;
14635 50152 break;
14636
14637 case r_down: //ul
14638 42370 flip=0;
14639 42370 tile+=20;
14640 42370 break;
14641
14642 case down: //ur
14643 40742 flip=0;
14644 40742 tile+=24;
14645 40742 break;
14646
14647 case r_up: //dl
14648 49191 flip=0;
14649 49191 tile+=28;
14650 49191 break;
14651
14652 case right: //dr
14653 53130 flip=0;
14654 53130 tile+=32;
14655 53130 break;
14656 }
14657 }
14658
14659 385733 tile+=f2;
14660 385733 }
14661
14662
2/2
✓ Branch 0 taken 22092 times.
✓ Branch 1 taken 440779 times.
462871 if(clk>=0)
14663 440779 enemy::draw(dest);
14664 462871 }
14665
14666 239 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14667 239 {
14668
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 if( !(editorflags & ENEMY_FLAG5) )
14669 {
14670
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 x=64;
14671
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 y=80;
14672 239 }
14673 //else { x = X; y = Y; }
14674 //zprint2("lanmola index is %d\n", index);
14675 //byte legaldirs = 0;
14676 239 int32_t incr = 16;
14677 //int32_t possiiblepos = 0;
14678 //int32_t positions[8] = {0};
14679
14680 //Don't spawn in pits.
14681
5/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 149 times.
✓ Branch 7 taken 90 times.
239 if ( m_walkflag_simple(x, y) )
14682 {
14683 //zprint2("Can't spawn here.\n");
14684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 for ( ; incr < 240; incr += 16 )
14685 {
14686 //move if we spawn over a pit
14687 //check each direction
14688
7/12
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 124 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 124 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 120 times.
124 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14689 {
14690 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14691
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
14692 }
14693
7/12
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 120 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 120 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 28 times.
✓ Branch 11 taken 92 times.
120 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14694 {
14695 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14696
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 x+=incr; break;
14697 }
14698
9/16
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 92 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 92 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 60 times.
92 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14699 {
14700 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14701
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
14702 }
14703
8/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 60 times.
60 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14704 {
14705 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14706 x+=incr; y-=incr; break;
14707 }
14708
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14709 {
14710 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14711 y -= incr; break;
14712 }
14713
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14714 {
14715 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14716 y+=incr; break;
14717 }
14718
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14719 {
14720 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14721
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
14722 }
14723
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14724 {
14725 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14726 x+=incr; y+=incr; break;
14727 }
14728 34 else continue;
14729
14730 }
14731
14732 90 }
14733
14734 239 dir=up;
14735 239 superman=1;
14736 239 fading=fade_invisible;
14737 239 hxofs=1000;
14738 239 segcnt=clk;
14739 239 clk=0;
14740 //set up move history
14741
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 1691 times.
1930 for(int32_t i=0; i <= (1<<dmisc2); i++)
14742
3/6
✓ Branch 0 taken 1691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1691 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1691 times.
✗ Branch 5 not taken.
1691 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14743 239 }
14744
14745 134485 bool eLanmola::animate(int32_t index)
14746 {
14747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134485 times.
134485 if(switch_hooked) return enemy::animate(index);
14748
2/2
✓ Branch 0 taken 112061 times.
✓ Branch 1 taken 22424 times.
134485 if(clk==0)
14749 {
14750 22424 removearmos(x,y,ffcactivated);
14751 22424 }
14752
14753
2/2
✓ Branch 0 taken 1862 times.
✓ Branch 1 taken 132623 times.
134485 if(clk2)
14754 {
14755
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 98 times.
1862 if(--clk2 == 0)
14756 {
14757
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 20 times.
98 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14758 78 leave_item();
14759
14760 98 stop_bgsfx(index);
14761 98 return true;
14762 }
14763
14764 1764 return false;
14765 }
14766
14767
14768 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14769 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14770 //I've added a complete movement history to this enemy to compensate -DD
14771 132623 constant_walk(rate,homing,spw_none);
14772 132623 prevState.pop_front();
14773 132623 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14774
14775 // This could cause a crash with Moldorms. I didn't see the same problem
14776 // with Lanmolas, but it looks like it ought to be possible, so here's
14777 // the same solution. - Saf
14778
1/2
✓ Branch 0 taken 132623 times.
✗ Branch 1 not taken.
132623 if(index+segcnt>=guys.Count())
14779 segcnt=guys.Count()-index-1;
14780
14781
2/2
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 599039 times.
731662 for(int32_t i=index+1; i<index+segcnt+1; i++)
14782 {
14783 599039 enemy* segment=((enemy*)guys.spr(i));
14784
14785 // More validation in case segcnt is wrong
14786
1/2
✓ Branch 0 taken 599039 times.
✗ Branch 1 not taken.
599039 if((segment->id&0xFFF)!=(id&0xFFF))
14787 {
14788 segcnt=i-index-1;
14789 break;
14790 }
14791
14792 599039 segment->o_tile=o_tile;
14793 599039 segment->parent_script_UID = this->script_UID;
14794
4/4
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 466416 times.
✓ Branch 2 taken 19514 times.
✓ Branch 3 taken 113109 times.
599039 if((i==index+segcnt)&&(i!=index+1))
14795 {
14796 113109 segment->dummy_int[1]=1; //tail
14797 113109 }
14798 else
14799 {
14800 485930 segment->dummy_int[1]=0;
14801 }
14802
14803
2/2
✓ Branch 0 taken 598467 times.
✓ Branch 1 taken 572 times.
599039 if(segment->hp <= 0)
14804 {
14805
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 977 times.
1549 for(int32_t j=i; j<index+segcnt; j++)
14806 {
14807 // Triple-check
14808
1/2
✓ Branch 0 taken 977 times.
✗ Branch 1 not taken.
977 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14809 {
14810 segcnt=j-index+1; // Add 1 because of --segcnt below
14811 break;
14812 }
14813 977 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14814 977 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14815 977 }
14816
14817 572 ((enemy*)guys.spr(i))->hclk=33;
14818 572 --segcnt;
14819 572 --i; // Recheck the same index in case multiple segments died at once
14820 572 }
14821 599039 }
14822
14823
2/2
✓ Branch 0 taken 132525 times.
✓ Branch 1 taken 98 times.
132623 if(segcnt==0)
14824 {
14825 98 clk2=19;
14826 98 x=guys.spr(index+1)->x;
14827 98 y=guys.spr(index+1)->y;
14828 98 setmapflag(mTMPNORET);
14829 98 }
14830
14831 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14832 //which is... disastrous.
14833 132623 hp = 1;
14834 132623 return enemy::animate(index);
14835 134485 }
14836
14837 1250 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14838 1250 {
14839
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 if( !(editorflags & ENEMY_FLAG5) )
14840 {
14841
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 x=64;
14842
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 y=80;
14843 1250 }
14844 1250 int32_t incr = 16;
14845 //Don't spawn in pits.
14846
5/8
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1250 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1250 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 450 times.
1250 if ( m_walkflag_simple(x, y) )
14847 {
14848 //zprint2("Can't spawn here.\n");
14849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
620 for ( ; incr < 240; incr += 16 )
14850 {
14851 //move if we spawn over a pit
14852 //check each direction
14853
7/12
✓ Branch 0 taken 620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 620 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 620 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 620 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 600 times.
620 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14854 {
14855 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14856
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14857 }
14858
7/12
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 600 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 600 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 140 times.
✓ Branch 11 taken 460 times.
600 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14859 {
14860 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14861
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 x+=incr; break;
14862 }
14863
9/16
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 460 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 460 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 460 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 460 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 300 times.
460 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14864 {
14865 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14866
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14867 }
14868
8/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 300 times.
300 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14869 {
14870 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14871 x+=incr; y-=incr; break;
14872 }
14873
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14874 {
14875 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14876 y -= incr; break;
14877 }
14878
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14879 {
14880 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14881 y+=incr; break;
14882 }
14883
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14884 {
14885 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14886
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14887 }
14888
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14889 {
14890 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14891 x+=incr; y+=incr; break;
14892 }
14893 170 else continue;
14894
14895 }
14896
14897 450 }
14898
14899 1250 hxofs=1000;
14900 1250 hit_width=8;
14901 1250 mainguy=false;
14902 1250 count_enemy=(id<0x2000)?true:false;
14903
14904 //set up move history
14905
2/2
✓ Branch 0 taken 1250 times.
✓ Branch 1 taken 8910 times.
10160 for(int32_t i=0; i <= (1<<dmisc2); i++)
14906
3/6
✓ Branch 0 taken 8910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8910 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8910 times.
✗ Branch 5 not taken.
8910 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14907
14908 1250 bgsfx = -1;
14909 1250 isCore = false;
14910 1250 flags&=~guy_neverret;
14911 1250 }
14912
14913 609335 bool esLanmola::animate(int32_t index)
14914 {
14915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 609335 times.
609335 if(switch_hooked) return enemy::animate(index);
14916 // Shouldn't be possible, but who knows
14917
1/2
✓ Branch 0 taken 609335 times.
✗ Branch 1 not taken.
609335 if(index==0)
14918 dying=true;
14919
14920
2/2
✓ Branch 0 taken 10296 times.
✓ Branch 1 taken 599039 times.
609335 if(dying)
14921 {
14922 10296 xofs=0;
14923
14924
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 8496 times.
10296 if(!dmisc3)
14925 8496 item_set=0;
14926
14927 10296 return Dead(index);
14928 }
14929
14930
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 579729 times.
599039 if(clk>=0)
14931 {
14932 579729 hxofs=4;
14933
14934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579729 times.
579729 if(!watch)
14935 {
14936 579729 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14937 579729 prevState.pop_front();
14938 579729 prevState.push_back(newstate);
14939 579729 x = newstate.first.first;
14940 579729 y = newstate.first.second;
14941 579729 dir = newstate.second;
14942 579729 }
14943 579729 }
14944
14945 599039 return enemy::animate(index);
14946 609335 }
14947
14948 1513 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14949 {
14950
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 131 times.
1513 if(enemy::takehit(w,realweap))
14951 1382 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14952
14953 131 return 0;
14954 1513 }
14955
14956 610611 void esLanmola::draw(BITMAP *dest)
14957 {
14958 610611 tile=o_tile;
14959 610611 int32_t fdiv = frate/4;
14960
1/2
✓ Branch 0 taken 610611 times.
✗ Branch 1 not taken.
610611 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14961
14962
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14963 610611 efrate:((clk>=(frate>>1))?1:0);
14964
14965
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 if(get_qr(qr_NEWENEMYTILES))
14966 {
14967
2/2
✓ Branch 0 taken 68269 times.
✓ Branch 1 taken 269264 times.
337533 if(id>=0x2000)
14968 {
14969 269264 tile+=20;
14970
14971
2/2
✓ Branch 0 taken 209782 times.
✓ Branch 1 taken 59482 times.
269264 if(dummy_int[1]==1)
14972 {
14973 59482 tile+=20;
14974 59482 }
14975 269264 }
14976
14977
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 70158 times.
✓ Branch 2 taken 71956 times.
✓ Branch 3 taken 93557 times.
✓ Branch 4 taken 101862 times.
337533 switch(dir)
14978 {
14979 case up:
14980 70158 flip=0;
14981 70158 break;
14982
14983 case down:
14984 71956 flip=0;
14985 71956 tile+=4;
14986 71956 break;
14987
14988 case left:
14989 93557 flip=0;
14990 93557 tile+=8;
14991 93557 break;
14992
14993 case right:
14994 101862 flip=0;
14995 101862 tile+=12;
14996 101862 break;
14997 }
14998
14999 337533 tile+=f2;
15000 337533 }
15001 else
15002 {
15003
2/2
✓ Branch 0 taken 66631 times.
✓ Branch 1 taken 206447 times.
273078 if(id>=0x2000)
15004 {
15005 206447 tile+=1;
15006 206447 }
15007 }
15008
15009
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 591301 times.
610611 if(clk>=0)
15010 591301 enemy::draw(dest);
15011 610611 }
15012
15013 59 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
15014 59 {
15015 //these are here to bypass compiler warnings about unused arguments
15016 59 Clk=Clk;
15017 59 superman=1;
15018
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 dir=(zc_oldrand()&7)+8;
15019 59 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
15020
15021
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 59 times.
327 for(int32_t i=0; i<armcnt; i++)
15022 268 arm[i]=i;
15023
15024 59 fading=fade_blue_poof;
15025 //nets+4680;
15026 59 adjusted=false;
15027 59 SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020
15028
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15029 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15030 // al_trace("Enemy txsz:%i\n", txsz);
15031
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15032
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15033
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15035
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15036
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15037 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15038
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15039
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15040 {
15041 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15042 }
15043
15044
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15045 59 }
15046
15047 30979 bool eManhandla::animate(int32_t index)
15048 {
15049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30979 times.
30979 if(switch_hooked) return enemy::animate(index);
15050
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 30209 times.
30979 if(dying)
15051 770 return Dead(index);
15052
15053
2/2
✓ Branch 0 taken 28958 times.
✓ Branch 1 taken 1251 times.
30209 if(clk==0)
15054 {
15055 1251 removearmos(x,y,ffcactivated);
15056 1251 }
15057
15058
15059 // check arm status, move dead ones to end of group
15060
2/2
✓ Branch 0 taken 94683 times.
✓ Branch 1 taken 30209 times.
124892 for(int32_t i=0; i<armcnt; i++)
15061 {
15062 94683 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
15063
3/4
✓ Branch 0 taken 94683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 94479 times.
94683 if(!cur_arm || cur_arm->dying)
15064 {
15065
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 204 times.
456 for(int32_t j=i; j<armcnt-1; j++)
15066 {
15067 252 zc_swap(arm[j],arm[j+1]);
15068 252 guys.swap(index+j+1,index+j+2);
15069 252 }
15070
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 36 times.
204 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
15071 {
15072 36 leave_item();
15073 36 }
15074 204 --armcnt;
15075 204 --i;
15076 204 continue;
15077 }
15078
2/2
✓ Branch 0 taken 94211 times.
✓ Branch 1 taken 268 times.
94479 if(!adjusted)
15079 {
15080
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 64 times.
268 if(!dmisc2)
15081 {
15082 204 cur_arm->o_tile=o_tile+40;
15083 204 cur_arm->parent_script_UID = this->script_UID;
15084 204 }
15085 else
15086 {
15087 64 cur_arm->o_tile=o_tile+160;
15088 64 cur_arm->parent_script_UID = this->script_UID;
15089 }
15090 268 }
15091 94479 }
15092
15093 30209 adjusted=true;
15094
15095 // move or die
15096
2/2
✓ Branch 0 taken 30166 times.
✓ Branch 1 taken 43 times.
30209 if(armcnt==0)
15097 43 hp=0;
15098 else
15099 {
15100 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
15101
2/2
✓ Branch 0 taken 27285 times.
✓ Branch 1 taken 2881 times.
30166 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
15102
1/2
✓ Branch 0 taken 30166 times.
✗ Branch 1 not taken.
30166 if (step > 4.5_zf) step = 4.5_zf;
15103 30166 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
15104
15105
2/2
✓ Branch 0 taken 27285 times.
✓ Branch 1 taken 2881 times.
30166 if(!dmisc2)
15106 {
15107
2/2
✓ Branch 0 taken 80492 times.
✓ Branch 1 taken 27285 times.
107777 for(int32_t i=0; i<armcnt; i++)
15108 {
15109
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18990 times.
✓ Branch 2 taken 21427 times.
✓ Branch 3 taken 19973 times.
✓ Branch 4 taken 20102 times.
80492 switch(arm[i])
15110 {
15111 case 0:
15112 18990 dy1=-24;
15113 18990 break;
15114
15115 case 1:
15116 21427 dy2=31;
15117 21427 break;
15118
15119 case 2:
15120 19973 dx1=-16;
15121 19973 break;
15122
15123 case 3:
15124 20102 dx2=31;
15125 20102 break;
15126 }
15127 80492 }
15128 27285 }
15129 else
15130 {
15131 2881 dx1=-8, dy1=-16, dx2=23, dy2=23;
15132
15133
2/2
✓ Branch 0 taken 13987 times.
✓ Branch 1 taken 2881 times.
16868 for(int32_t i=0; i<armcnt; i++)
15134 {
15135
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4279 times.
✓ Branch 2 taken 3184 times.
✓ Branch 3 taken 2549 times.
✓ Branch 4 taken 3975 times.
13987 switch(arm[i]&3)
15136 {
15137 case 0:
15138 4279 dy1=-32;
15139 4279 break;
15140
15141 case 1:
15142 3184 dy2=39;
15143 3184 break;
15144
15145 case 2:
15146 2549 dx1=-24;
15147 2549 break;
15148
15149 case 3:
15150 3975 dx2=39;
15151 3975 break;
15152 }
15153 13987 }
15154 }
15155
15156 30166 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
15157
15158
2/2
✓ Branch 0 taken 94479 times.
✓ Branch 1 taken 30166 times.
124645 for(int32_t i=0; i<armcnt; i++)
15159 {
15160 94479 zfix dx=(zfix)0,dy=(zfix)0;
15161
15162
2/2
✓ Branch 0 taken 80492 times.
✓ Branch 1 taken 13987 times.
94479 if(!dmisc2)
15163 {
15164
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18990 times.
✓ Branch 2 taken 21427 times.
✓ Branch 3 taken 19973 times.
✓ Branch 4 taken 20102 times.
80492 switch(arm[i])
15165 {
15166 case 0:
15167 18990 dy=-16;
15168 18990 break;
15169
15170 case 1:
15171 21427 dy=16;
15172 21427 break;
15173
15174 case 2:
15175 19973 dx=-16;
15176 19973 break;
15177
15178 case 3:
15179 20102 dx=16;
15180 20102 break;
15181 }
15182 80492 }
15183 else
15184 {
15185
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✓ Branch 2 taken 1789 times.
✓ Branch 3 taken 1292 times.
✓ Branch 4 taken 2015 times.
✓ Branch 5 taken 2599 times.
✓ Branch 6 taken 1395 times.
✓ Branch 7 taken 1257 times.
✓ Branch 8 taken 1960 times.
13987 switch(arm[i])
15186 {
15187 case 0:
15188 1680 dy=-24;
15189 1680 dx=-8;
15190 1680 break;
15191
15192 case 1:
15193 1789 dy=24;
15194 1789 dx=8;
15195 1789 break;
15196
15197 case 2:
15198 1292 dx=-24;
15199 1292 dy=8;
15200 1292 break;
15201
15202 case 3:
15203 2015 dx=24;
15204 2015 dy=-8;
15205 2015 break;
15206
15207 case 4:
15208 2599 dy=-24;
15209 2599 dx=8;
15210 2599 break;
15211
15212 case 5:
15213 1395 dy=24;
15214 1395 dx=-8;
15215 1395 break;
15216
15217 case 6:
15218 1257 dx=-24;
15219 1257 dy=-8;
15220 1257 break;
15221
15222 case 7:
15223 1960 dx=24;
15224 1960 dy=8;
15225 1960 break;
15226 }
15227 }
15228
15229 94479 guys.spr(index+i+1)->x = x+dx;
15230 94479 guys.spr(index+i+1)->y = y+dy;
15231 94479 }
15232 }
15233
15234 30209 return enemy::animate(index);
15235 30979 }
15236
15237
15238 1338 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
15239 {
15240 1338 int32_t wpnId = w->id;
15241
15242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1338 times.
1338 if(dying)
15243 return 0;
15244
15245
3/4
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1338 switch(wpnId)
15246 {
15247 case wBomb:
15248 case wSBomb:
15249 case wSword:
15250 case wHammer:
15251 case wWand:
15252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 448 times.
448 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15253
15254 case wLitBomb:
15255 case wLitSBomb:
15256 case wBait:
15257 case wWhistle:
15258 case wFire:
15259 case wWind:
15260 case wSSparkle:
15261 case wFSparkle:
15262 case wPhantom:
15263 1321 return 0;
15264
15265 case wHookshot:
15266 case wBrang:
15267 sfx(WAV_CHINK,pan(int32_t(x)));
15268 break;
15269
15270 default:
15271
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15272 else sfx(WAV_CHINK,pan(int32_t(x)));
15273
15274 17 }
15275
15276 17 return 1;
15277 1338 }
15278
15279 30977 void eManhandla::draw(BITMAP *dest)
15280 {
15281 30977 tile=o_tile;
15282 30977 int32_t fdiv = frate/4;
15283
1/2
✓ Branch 0 taken 30977 times.
✗ Branch 1 not taken.
30977 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15284
15285
2/2
✓ Branch 0 taken 22018 times.
✓ Branch 1 taken 8959 times.
30977 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15286 30977 efrate:((clk>=(frate>>1))?1:0);
15287
15288
2/2
✓ Branch 0 taken 22018 times.
✓ Branch 1 taken 8959 times.
30977 if(get_qr(qr_NEWENEMYTILES))
15289 {
15290
2/2
✓ Branch 0 taken 2518 times.
✓ Branch 1 taken 19500 times.
22018 if(!dmisc2)
15291 {
15292
8/9
✓ Branch 0 taken 2465 times.
✓ Branch 1 taken 2274 times.
✓ Branch 2 taken 2799 times.
✓ Branch 3 taken 2974 times.
✓ Branch 4 taken 1879 times.
✓ Branch 5 taken 1895 times.
✓ Branch 6 taken 2025 times.
✓ Branch 7 taken 3189 times.
✗ Branch 8 not taken.
19500 switch(dir-8) //directions get screwed up after 8. *shrug*
15293 {
15294 case up: //u
15295 2465 flip=0;
15296 2465 break;
15297
15298 case l_up: //d
15299 2274 flip=0;
15300 2274 tile+=4;
15301 2274 break;
15302
15303 case l_down: //l
15304 2799 flip=0;
15305 2799 tile+=8;
15306 2799 break;
15307
15308 case left: //r
15309 2974 flip=0;
15310 2974 tile+=12;
15311 2974 break;
15312
15313 case r_down: //ul
15314 1879 flip=0;
15315 1879 tile+=20;
15316 1879 break;
15317
15318 case down: //ur
15319 1895 flip=0;
15320 1895 tile+=24;
15321 1895 break;
15322
15323 case r_up: //dl
15324 2025 flip=0;
15325 2025 tile+=28;
15326 2025 break;
15327
15328 case right: //dr
15329 3189 flip=0;
15330 3189 tile+=32;
15331 3189 break;
15332 }
15333
15334 19500 tile+=f2;
15335 19500 enemy::draw(dest);
15336 19500 } //manhandla 2, big body
15337 else
15338 {
15339
15340
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 500 times.
✓ Branch 4 taken 315 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 164 times.
✓ Branch 8 taken 288 times.
2518 switch(dir-8) //directions get screwed up after 8. *shrug*
15341 {
15342 case up: //u
15343 357 flip=0;
15344 357 break;
15345
15346 case l_up: //d
15347 483 flip=0;
15348 483 tile+=8;
15349 483 break;
15350
15351 case l_down: //l
15352 500 flip=0;
15353 500 tile+=40;
15354 500 break;
15355
15356 case left: //r
15357 315 flip=0;
15358 315 tile+=48;
15359 315 break;
15360
15361 case r_down: //ul
15362 196 flip=0;
15363 196 tile+=80;
15364 196 break;
15365
15366 case down: //ur
15367 215 flip=0;
15368 215 tile+=88;
15369 215 break;
15370
15371 case r_up: //dl
15372 164 flip=0;
15373 164 tile+=120;
15374 164 break;
15375
15376 case right: //dr
15377 288 flip=0;
15378 288 tile+=128;
15379 288 break;
15380 }
15381
15382 2518 tile+=(f2*2);
15383 2518 xofs-=8;
15384 2518 yofs-=8;
15385 2518 drawblock(dest,15);
15386 2518 xofs+=8;
15387 2518 yofs+=8;
15388 }
15389 22018 }
15390 else
15391 {
15392
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 8444 times.
8959 if(!dmisc2)
15393 {
15394 8444 enemy::draw(dest);
15395 8444 }
15396 else
15397 {
15398 515 xofs-=8;
15399 515 yofs-=8;
15400 515 enemy::draw(dest);
15401 515 xofs+=16;
15402 515 enemy::draw(dest);
15403 515 yofs+=16;
15404 515 enemy::draw(dest);
15405 515 xofs-=16;
15406 515 enemy::draw(dest);
15407 515 xofs+=8;
15408 515 yofs-=8;
15409 }
15410 }
15411 30977 }
15412
15413 268 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15414 268 {
15415 268 id=misc=clk;
15416 268 dir = clk & 3;
15417 268 clk=0;
15418 268 mainguy=count_enemy=false;
15419 268 dummy_bool[0]=false;
15420 268 item_set=0;
15421 268 bgsfx=-1;
15422 268 deadsfx = WAV_EDEAD;
15423 268 flags &= (~guy_neverret);
15424 268 isCore = false;
15425 //Probably will be buggy. -Z 12 AUG 2020
15426 268 SIZEflags = d->SIZEflags;
15427
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15428 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15429 // al_trace("Enemy txsz:%i\n", txsz);
15430
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15431
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15432
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15434
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15435
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15436 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15437
1/4
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15438
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15439 {
15440 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15441 }
15442
15443
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15444 268 }
15445
15446 98135 bool esManhandla::animate(int32_t index)
15447 {
15448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98135 times.
98135 if(switch_hooked) return enemy::animate(index);
15449
2/2
✓ Branch 0 taken 3656 times.
✓ Branch 1 taken 94479 times.
98135 if(dying)
15450 3656 return Dead(index);
15451
15452
2/2
✓ Branch 0 taken 6029 times.
✓ Branch 1 taken 88450 times.
94479 if(clk==0)
15453 {
15454 6029 removearmos(x,y,ffcactivated);
15455 6029 }
15456
15457
2/2
✓ Branch 0 taken 80858 times.
✓ Branch 1 taken 13621 times.
94479 if(--clk2<=0)
15458 {
15459 13621 clk2=unsigned(zc_oldrand())%5+5;
15460 13621 clk3^=1;
15461 13621 }
15462
15463
2/2
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 93728 times.
94479 if(!(zc_oldrand()&127))
15464 {
15465 751 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
15466 751 sfx(wpnsfx(wpn),pan(int32_t(x)));
15467 751 }
15468
15469 94479 return enemy::animate(index);
15470 98135 }
15471
15472 98127 void esManhandla::draw(BITMAP *dest)
15473 {
15474 98127 tile=o_tile;
15475 98127 int32_t fdiv = frate/4;
15476
1/2
✓ Branch 0 taken 98127 times.
✗ Branch 1 not taken.
98127 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15477
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 25181 times.
98127 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15478 98127 efrate:((clk>=(frate>>1))?1:0);
15479
15480
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 25181 times.
98127 if(get_qr(qr_NEWENEMYTILES))
15481 {
15482
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17260 times.
✓ Branch 2 taken 19375 times.
✓ Branch 3 taken 18024 times.
✓ Branch 4 taken 18287 times.
72946 switch(misc&3)
15483 {
15484 case up:
15485 17260 break;
15486
15487 case down:
15488 19375 tile+=4;
15489 19375 break;
15490
15491 case left:
15492 18024 tile+=8;
15493 18024 break;
15494
15495 case right:
15496 18287 tile+=12;
15497 18287 break;
15498 }
15499
15500 72946 tile+=f2;
15501 72946 }
15502 else
15503 {
15504
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6921 times.
✓ Branch 2 taken 5410 times.
✓ Branch 3 taken 6148 times.
✓ Branch 4 taken 6702 times.
25181 switch(misc&3)
15505 {
15506 case down:
15507 6148 flip=2;
15508
15509 [[fallthrough]];
15510 case up:
15511 13069 tile=(clk3)?188:189;
15512 13069 break;
15513
15514 case right:
15515 6702 flip=1;
15516 [[fallthrough]];
15517
15518 case left:
15519 12112 tile=(clk3)?186:187;
15520 12112 break;
15521 }
15522 }
15523
15524 98127 enemy::draw(dest);
15525 98127 }
15526
15527 94 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
15528 94 {
15529
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( !(editorflags & ENEMY_FLAG5) )
15530 {
15531
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 x = 120;
15532
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 y = 48;
15533 94 }
15534 else
15535 {
15536 if ( !(editorflags & ENEMY_FLAG6) )
15537 {
15538 x = X; y = Y;
15539 }
15540 else
15541 {
15542 x = X+8; y = Y;
15543 }
15544 }
15545 94 hzsz = 32; // can't be jumped.
15546 94 flameclk=0;
15547 94 misc=clk; // total head count
15548 94 clk3=clk; // live head count
15549 94 clk=0;
15550 94 clk2=60; // fire ball clock
15551 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
15552
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
15553 94 dir = down;
15554 94 hxofs=4;
15555 94 hit_width=8;
15556 // frate=17*4;
15557 94 fading=fade_blue_poof;
15558 //nets+5420;
15559
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 23 times.
94 if(get_qr(qr_NEWENEMYTILES))
15560 {
15561 /*
15562 necktile=o_tile+8;
15563 if (dmisc3)
15564 {
15565 necktile+=8;
15566 }
15567 */
15568 71 necktile=o_tile+dmisc6;
15569 71 }
15570 else
15571 {
15572 23 necktile=s_tile;
15573 }
15574 94 }
15575
15576 70509 bool eGleeok::animate(int32_t index)
15577 {
15578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70509 times.
70509 if(switch_hooked) return enemy::animate(index);
15579
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 69261 times.
70509 if(dying)
15580 1248 return Dead(index);
15581
15582
2/2
✓ Branch 0 taken 68945 times.
✓ Branch 1 taken 316 times.
69261 if(clk==0)
15583 {
15584 316 removearmos(x,y,ffcactivated);
15585 316 }
15586
15587 // Check if a head was killed somehow...
15588
2/2
✓ Branch 0 taken 35220 times.
✓ Branch 1 taken 34041 times.
69261 if(index+1+clk3>=guys.Count())
15589 34041 clk3=guys.Count()-index-1;
15590
2/2
✓ Branch 0 taken 13804 times.
✓ Branch 1 taken 55457 times.
69261 if(index+1+misc>=guys.Count())
15591 55457 misc=guys.Count()-index-1;
15592
15593 //fix for the "kill all enemies" item
15594
2/2
✓ Branch 0 taken 69255 times.
✓ Branch 1 taken 6 times.
69261 if(hp==-1000)
15595 {
15596
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
15597 {
15598 // I haven't seen this fail, but it seems like it ought to be
15599 // possible, so I'm checking for it. - Saf
15600
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15601 break;
15602 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
15603 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
15604 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
15605 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
15606 12 }
15607
15608 6 clk3=0;
15609
15610
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
15611 {
15612
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15613 break;
15614 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15615 12 }
15616 6 }
15617
15618
2/2
✓ Branch 0 taken 157172 times.
✓ Branch 1 taken 69261 times.
226433 for(int32_t i=0; i<clk3; i++)
15619 {
15620 157172 enemy *head = ((enemy*)guys.spr(index+i+1));
15621 157172 head->dummy_int[1]=necktile;
15622 157172 head->parent_script_UID = this->script_UID;
15623
15624
2/2
✓ Branch 0 taken 103123 times.
✓ Branch 1 taken 54049 times.
157172 if(get_qr(qr_NEWENEMYTILES))
15625 {
15626 103123 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
15627 103123 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
15628 103123 }
15629 else
15630 {
15631 54049 head->dummy_int[2]=necktile+1; //connected head tile
15632 54049 head->dummy_int[3]=necktile+2; //flying head tile
15633 }
15634
15635 157172 head->dmisc5=dmisc5; //neck segments
15636
15637 /*
15638 if (dmisc3)
15639 {
15640 head->dummy_bool[0]=true;
15641 }
15642 */
15643
2/2
✓ Branch 0 taken 154379 times.
✓ Branch 1 taken 2793 times.
157172 if(head->hclk)
15644 {
15645
2/2
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 569 times.
2793 if(hclk==0)
15646 {
15647 569 hp -= 1000 - head->hp;
15648 569 hclk = 33;
15649
15650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 569 times.
569 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
15651
15652 569 sfx(WAV_EHIT,pan(int32_t(head->x)));
15653 569 }
15654
15655 2793 head->hclk = 0;
15656 2793 }
15657
15658 // Must be set in case of naughty ZScripts
15659 157172 head->hp = 1000;
15660 157172 }
15661
15662
2/2
✓ Branch 0 taken 69069 times.
✓ Branch 1 taken 192 times.
69261 if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult())
15663 {
15664 192 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
15665 192 hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult();
15666 192 }
15667
15668
2/2
✓ Branch 0 taken 19312 times.
✓ Branch 1 taken 49949 times.
69261 if(!dmisc3)
15669 {
15670
4/4
✓ Branch 0 taken 2801 times.
✓ Branch 1 taken 47148 times.
✓ Branch 2 taken 674 times.
✓ Branch 3 taken 2127 times.
49949 if(++clk2>72 && !(zc_oldrand()&3))
15671 {
15672 674 int32_t i=zc_oldrand()%misc;
15673 674 enemy *head = ((enemy*)guys.spr(index+i+1));
15674 674 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
15675 674 sfx(wpnsfx(wpn),pan(int32_t(x)));
15676 674 clk2=0;
15677 674 }
15678 49949 }
15679 else
15680 {
15681
4/4
✓ Branch 0 taken 827 times.
✓ Branch 1 taken 18485 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 189 times.
19312 if(++clk2>100 && !(zc_oldrand()&3))
15682 {
15683 189 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
15684 189 head->timer=zc_oldrand()%50+50;
15685 189 clk2=0;
15686 189 }
15687 }
15688
15689
3/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 69191 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
69261 if((hp<=0 && !immortal))
15690 {
15691
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 70 times.
256 for(int32_t i=0; i<misc; i++)
15692 186 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15693
15694
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 67 times.
70 if(flags&guy_neverret) never_return(index);
15695 70 }
15696
15697 69261 return enemy::animate(index);
15698 70509 }
15699
15700 155 int32_t eGleeok::takehit(weapon*,weapon*)
15701 {
15702 155 return 0;
15703 }
15704
15705 70829 void eGleeok::draw(BITMAP *dest)
15706 {
15707 70829 tile=o_tile;
15708
15709
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 69581 times.
70829 if(dying)
15710 {
15711 1248 enemy::draw(dest);
15712 1248 return;
15713 }
15714
15715 69581 int32_t f=clk/17;
15716
15717
2/2
✓ Branch 0 taken 46906 times.
✓ Branch 1 taken 22675 times.
69581 if(get_qr(qr_NEWENEMYTILES))
15718 {
15719 // body
15720 46906 xofs=-8;
15721 46906 yofs=32;
15722
15723
4/4
✓ Branch 0 taken 35926 times.
✓ Branch 1 taken 3851 times.
✓ Branch 2 taken 3602 times.
✓ Branch 3 taken 3527 times.
46906 switch(f)
15724
15725 {
15726 case 0:
15727 3851 tile+=0;
15728 3851 break;
15729
15730 case 1:
15731 3602 tile+=2;
15732 3602 break;
15733
15734 case 2:
15735 3527 tile+=4;
15736 3527 break;
15737
15738 default:
15739 35926 tile+=6;
15740 35926 break;
15741 }
15742 46906 }
15743 else
15744 {
15745 // body
15746 22675 xofs=-8;
15747 22675 yofs=32;
15748
15749
3/3
✓ Branch 0 taken 19415 times.
✓ Branch 1 taken 1645 times.
✓ Branch 2 taken 1615 times.
22675 switch(f)
15750 {
15751 case 0:
15752 1645 tile+=0;
15753 1645 break;
15754
15755 case 2:
15756 1615 tile+=4;
15757 1615 break;
15758
15759 default:
15760 19415 tile+=2;
15761 19415 break;
15762 }
15763 }
15764
15765 69581 enemy::drawblock(dest,15);
15766 70829 }
15767
15768 70829 void eGleeok::draw2(BITMAP *dest)
15769 {
15770 // the neck stub
15771 70829 tile=necktile;
15772 70829 xofs=0;
15773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70829 times.
70829 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15774
15775
2/2
✓ Branch 0 taken 23071 times.
✓ Branch 1 taken 47758 times.
70829 if(get_qr(qr_NEWENEMYTILES))
15776 {
15777 47758 tile+=((clk&24)>>3);
15778 47758 }
15779
15780
3/4
✓ Branch 0 taken 69581 times.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69581 times.
70829 if(hp > 0 && !dont_draw())
15781 {
15782
4/4
✓ Branch 0 taken 1374 times.
✓ Branch 1 taken 68207 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 637 times.
69581 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15783 737 sprite::drawcloaked(dest);
15784 else
15785 68844 sprite::draw(dest);
15786 69581 }
15787 70829 }
15788
15789
3/6
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
536 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15790 268 {
15791
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 xoffset=0;
15792
2/4
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
268 yoffset=(zfix)((dmisc5*4+2));
15793 // dummy_bool[0]=false;
15794 268 timer=0;
15795 /* fixing */
15796 268 hp=1000;
15797
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 step=1;
15798 268 item_set=0;
15799 //x=120; y=70;
15800
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
268 x = xoffset+parent->x;
15801
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
268 y = yoffset+parent->y;
15802 268 hxofs=4;
15803 268 hit_width=8;
15804
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
268 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15805 268 clk2=clk; // how int32_t to wait before moving first time
15806 268 clk=0;
15807 268 mainguy=count_enemy=false;
15808
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 dir=zc_oldrand();
15809 268 clk3=((dir&2)>>1)+2; // left or right
15810 268 dir&=1; // up or down
15811
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 dmisc5=vbound(dmisc5,1,255);
15812 268 isCore = false;
15813
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 parentCore = parent->getUID();
15814
2/2
✓ Branch 0 taken 1072 times.
✓ Branch 1 taken 268 times.
1340 for(int32_t i=0; i<dmisc5; i++)
15815 {
15816 1072 nxoffset[i] = 0;
15817 1072 nyoffset[i] = 0;
15818
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
1072 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15819
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
1072 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15820 1072 }
15821
15822 268 necktile=0;
15823 //TODO compatibility? -DD
15824 /*
15825 for(int32_t i=0; i<4; i++)
15826 {
15827 nx[i]=124;
15828 ny[i]=i*6+48;
15829 }*/
15830 268 bgsfx=-1;
15831 //no need for deadsfx
15832 268 }
15833
15834 202199 bool esGleeok::animate(int32_t index)
15835 {
15836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202199 times.
202199 if(switch_hooked) return enemy::animate(index);
15837 // don't call removearmos() - it's a segment.
15838
15839 202199 dmisc5=vbound(dmisc5,1,255);
15840
15841
2/2
✓ Branch 0 taken 45213 times.
✓ Branch 1 taken 156986 times.
202199 if(misc == 0)
15842 {
15843 156986 x = (xoffset+parent->x);
15844 156986 y = (yoffset+parent->y);
15845
15846
2/2
✓ Branch 0 taken 627944 times.
✓ Branch 1 taken 156986 times.
784930 for(int32_t i=0; i<dmisc5; i++)
15847 {
15848 627944 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15849 627944 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15850 627944 }
15851 156986 }
15852
15853 // set up the head tiles
15854 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15855 /*
15856 if (dummy_bool[0]) //if this is a flame gleeok
15857 {
15858 headtile+=180;
15859 }
15860 */
15861 202199 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15862 202199 flyingheadtile=dummy_int[3];
15863
15864 // set up the neck tiles
15865 202199 necktile=dummy_int[1];
15866
15867
2/2
✓ Branch 0 taken 74462 times.
✓ Branch 1 taken 127737 times.
202199 if(get_qr(qr_NEWENEMYTILES))
15868 {
15869 127737 necktile+=((clk&24)>>3);
15870 127737 }
15871
15872 /*
15873 else
15874 {
15875 necktile=145;
15876 }
15877 */
15878 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15879
15880
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 156986 times.
✓ Branch 2 taken 44881 times.
✓ Branch 3 taken 134 times.
✓ Branch 4 taken 198 times.
202199 switch(misc)
15881 {
15882 case 0: // live head
15883 // set up the attached head tiles
15884 156986 tile=headtile;
15885
15886
2/2
✓ Branch 0 taken 53978 times.
✓ Branch 1 taken 103008 times.
156986 if(get_qr(qr_NEWENEMYTILES))
15887 {
15888 103008 tile+=((clk&24)>>3);
15889 /*
15890 if (dummy_bool[0]) {
15891 tile+=1561;
15892 }
15893 */
15894 103008 }
15895
15896 /*
15897 else
15898 {
15899 tile=146;
15900 }
15901 */
15902
4/4
✓ Branch 0 taken 40101 times.
✓ Branch 1 taken 116885 times.
✓ Branch 2 taken 4484 times.
✓ Branch 3 taken 35617 times.
156986 if(++clk2>=0 && !(clk2&3))
15903 {
15904
2/2
✓ Branch 0 taken 34833 times.
✓ Branch 1 taken 784 times.
35617 if(y<= (int32_t)parent->y + 8) dir=down;
15905
15906
2/2
✓ Branch 0 taken 34879 times.
✓ Branch 1 taken 738 times.
35617 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15907
15908
4/4
✓ Branch 0 taken 3728 times.
✓ Branch 1 taken 31889 times.
✓ Branch 2 taken 3626 times.
✓ Branch 3 taken 102 times.
35617 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15909 {
15910 102 dir^=1;
15911 102 }
15912
15913 35617 zfix tempx = x;
15914 35617 zfix tempy = y;
15915
15916 35617 sprite::move(step);
15917 35617 xoffset += (x-tempx);
15918 35617 yoffset += (y-tempy);
15919
15920
2/2
✓ Branch 0 taken 1490 times.
✓ Branch 1 taken 34127 times.
35617 if(clk2>=4)
15921 {
15922 1490 clk3^=1;
15923 1490 clk2=-4;
15924 1490 }
15925 else
15926 {
15927
2/2
✓ Branch 0 taken 33778 times.
✓ Branch 1 taken 349 times.
34127 if(x <= (int32_t)parent->x-(dmisc5*6))
15928 {
15929 349 clk3=right;
15930 349 }
15931
15932
2/2
✓ Branch 0 taken 33743 times.
✓ Branch 1 taken 384 times.
34127 if(x >= (int32_t)parent->x+(dmisc5*6))
15933 {
15934 384 clk3=left;
15935 384 }
15936
15937
4/4
✓ Branch 0 taken 23003 times.
✓ Branch 1 taken 11124 times.
✓ Branch 2 taken 21599 times.
✓ Branch 3 taken 1404 times.
34127 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15938 {
15939 1404 clk3^=1; // x jig
15940 1404 }
15941 else
15942 {
15943
4/4
✓ Branch 0 taken 11258 times.
✓ Branch 1 taken 21465 times.
✓ Branch 2 taken 10924 times.
✓ Branch 3 taken 334 times.
32723 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15944 {
15945 334 clk3^=1; // x switch back
15946 334 }
15947
15948 32723 clk2=-4;
15949 }
15950 }
15951
15952 35617 zc_swap(dir,clk3);
15953 35617 tempx = x;
15954 35617 tempy = y;
15955 35617 sprite::move(step);
15956 35617 xoffset += (x-tempx);
15957 35617 yoffset += (y-tempy);
15958 35617 zc_swap(dir,clk3);
15959
15960
2/2
✓ Branch 0 taken 106851 times.
✓ Branch 1 taken 35617 times.
142468 for(int32_t i=1; i<dmisc5; i++)
15961 {
15962 106851 nxoffset[i] = (zc_oldrand()%3);
15963 106851 nyoffset[i] = (zc_oldrand()%3);
15964 106851 }
15965 35617 }
15966
15967 156986 break;
15968
15969 case 1: // flying head
15970
2/2
✓ Branch 0 taken 2806 times.
✓ Branch 1 taken 42075 times.
44881 if(clk>=0)
15971
15972 {
15973 42075 variable_walk_8(rate,homing,hrate,spw_floater);
15974 42075 }
15975
15976 44881 break;
15977
15978 // the following are messages sent from the main guy...
15979 case -1: // got chopped off
15980 {
15981 134 misc=1;
15982 134 superman=1;
15983 134 hxofs=xofs=0;
15984 134 hit_width=16;
15985 134 cs=8;
15986 134 clk=-24;
15987 134 clk2=40;
15988 134 dir=(zc_oldrand()&7)+8;
15989 134 step=8.0/9.0;
15990 }
15991 134 break;
15992
15993 case -2: // the big guy is dead
15994 198 return true;
15995 }
15996
15997
2/2
✓ Branch 0 taken 189247 times.
✓ Branch 1 taken 12754 times.
202001 if(timer)
15998 {
15999
2/2
✓ Branch 0 taken 11233 times.
✓ Branch 1 taken 1521 times.
12754 if(!(timer%8))
16000 {
16001 1521 FireBreath(true);
16002 1521 }
16003
16004 12754 --timer;
16005 12754 }
16006
16007 202001 return enemy::animate(index);
16008 202199 }
16009
16010 3434 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
16011 {
16012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3434 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3434 if ((editorflags & ENEMY_FLAG7) && misc == 1)
16013 {
16014 int32_t wpnId = w->id;
16015
16016 if(dying)
16017 return 0;
16018
16019 switch(wpnId)
16020 {
16021 case wLitBomb:
16022 case wLitSBomb:
16023 case wBait:
16024 case wWhistle:
16025 case wFire:
16026 case wWind:
16027 case wSSparkle:
16028 case wFSparkle:
16029 case wPhantom:
16030 return 0;
16031
16032 case wHookshot:
16033 case wBrang:
16034 case wBeam:
16035 case wArrow:
16036 case wMagic:
16037 case wBomb:
16038 case wSBomb:
16039 sfx(WAV_CHINK,pan(int32_t(x)));
16040 break;
16041 default:
16042 break;
16043 }
16044
16045 return 1;
16046 }
16047 else
16048 {
16049 3434 int32_t ret = enemy::takehit(w,realweap);
16050
16051
2/2
✓ Branch 0 taken 641 times.
✓ Branch 1 taken 2793 times.
3434 if(ret==-1)
16052 2793 return 2; // force it to wait a frame before checking sword attacks again
16053
16054 641 return ret;
16055 }
16056 3434 }
16057
16058 202887 void esGleeok::draw(BITMAP *dest)
16059 {
16060 202887 dmisc5=vbound(dmisc5,1,255);
16061
16062
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 157884 times.
✓ Branch 2 taken 45003 times.
202887 switch(misc)
16063 {
16064 case 0: //neck
16065
1/2
✓ Branch 0 taken 157884 times.
✗ Branch 1 not taken.
157884 if(!dont_draw())
16066 {
16067
2/2
✓ Branch 0 taken 473652 times.
✓ Branch 1 taken 157884 times.
631536 for(int32_t i=1; i<dmisc5; i++) //draw the neck
16068 {
16069
2/2
✓ Branch 0 taken 311511 times.
✓ Branch 1 taken 162141 times.
473652 if(get_qr(qr_NEWENEMYTILES))
16070 {
16071
3/4
✓ Branch 0 taken 2211 times.
✓ Branch 1 taken 309300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2211 times.
311511 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16072 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
16073 else
16074 309300 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
16075 311511 }
16076 else
16077 {
16078
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 157863 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
162141 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16079 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
16080 else
16081 162141 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
16082 }
16083 473652 }
16084 157884 }
16085
16086 157884 break;
16087
16088 case 1: //flying head
16089 45003 tile=flyingheadtile;
16090
16091
2/2
✓ Branch 0 taken 24590 times.
✓ Branch 1 taken 20413 times.
45003 if(get_qr(qr_NEWENEMYTILES))
16092 {
16093 24590 tile+=((clk&24)>>3);
16094 24590 break;
16095 }
16096
16097 /*
16098 else
16099 {
16100 tile=(clk&1)?147:148;
16101 break;
16102 }
16103 */
16104 20413 }
16105 202887 }
16106
16107 202887 void esGleeok::draw2(BITMAP *dest)
16108 {
16109 202887 enemy::draw(dest);
16110 202887 }
16111
16112 53 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
16113 53 {
16114
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( !(editorflags & ENEMY_FLAG5) )
16115 {
16116
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 x = 128;
16117
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 y = 48;
16118 53 }
16119 else { x = X; y = Y; }
16120 53 adjusted=false;
16121
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 dir=(zc_oldrand()&7)+8;
16122 //step=0.25;
16123 53 flycnt=dmisc1;
16124 53 flycnt2=dmisc2;
16125 53 loopcnt=0;
16126 53 clk4 = 0;
16127 53 clk5 = 0;
16128 53 clk6 = 0;
16129 53 clk7 = 0;
16130
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16131 53 SIZEflags = d->SIZEflags;
16132
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16133
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16134 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16135 // al_trace("Enemy txsz:%i\n", txsz);
16136
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
16137
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16138
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
16139
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) hit_width = 32;
16140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
16141
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
16142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
16143
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) hxofs = -8;
16144
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
16145 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16146
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
16147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 else if (dmisc10 == 1) xofs = -8;
16148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16149 {
16150 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16151 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
16152 }
16153
1/6
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8;
16154
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (editorflags & ENEMY_FLAG8) misc = 1;
16155
16156
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
16157
16158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc29 == 0)
16159 {
16160
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16161 {
16162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc29 = (90 / 3);
16163 33 else dmisc29 = (84 / 3);
16164 33 }
16165 else
16166 {
16167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc29 = (90 / 2);
16168 20 else dmisc29 = (84 / 2);
16169 }
16170 53 }
16171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc30 == 0)
16172 {
16173
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16174 {
16175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc30 = (90 / 3)*0.5;
16176 33 else dmisc30 = (84 / 3)*0.5;
16177 33 }
16178 else
16179 {
16180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc30 = (90 / 2)*0.5;
16181 20 else dmisc30 = (84 / 2)*0.5;
16182 }
16183 53 }
16184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc31 == 0)
16185 {
16186
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16187 {
16188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc31 = (90 / 3)*2;
16189 33 else dmisc31 = (84 / 3)*2;
16190 33 }
16191 else
16192 {
16193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc31 = (90 / 2)*0.5;
16194 20 else dmisc31 = (84 / 2)*0.5;
16195 }
16196 53 }
16197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc32 == 0)
16198 {
16199
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16200 {
16201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc32 = (90 / 3);
16202 33 else dmisc32 = (84 / 3);
16203 33 }
16204 else
16205 {
16206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc32 = (90 / 2)*0.25;
16207 20 else dmisc32 = (84 / 2)*0.25;
16208 }
16209 53 }
16210 53 }
16211
16212 62362 bool ePatra::animate(int32_t index)
16213 {
16214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62362 times.
62362 if(switch_hooked) return enemy::animate(index);
16215
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 61552 times.
62362 if(dying)
16216 {
16217
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 810 times.
882 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
16218 {
16219 72 ((enemy*)guys.spr(i))->hp = -1000;
16220 72 }
16221
16222 810 return Dead(index);
16223 }
16224
16225 61552 double basesize = 84;
16226
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (dmisc10) basesize = 90;
16227 61552 double halfsize = basesize / 2;
16228 61552 double quartersize = halfsize / 2;
16229 61552 double twothirdsize = (basesize / 3)*2;
16230 61552 double onethirdsize = (basesize / 3);
16231
16232
16233
2/2
✓ Branch 0 taken 47886 times.
✓ Branch 1 taken 13666 times.
61552 if(clk==0)
16234 {
16235 13666 removearmos(x,y,ffcactivated);
16236 13666 }
16237
16238
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61552 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
61552 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
16239 {
16240
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61552 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
16241
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (loopcnt < 0) ++clk2;
16242
2/2
✓ Branch 0 taken 60857 times.
✓ Branch 1 taken 695 times.
61552 if(++clk2>basesize)
16243 {
16244 695 clk2=0;
16245
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 695 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
695 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
16246 {
16247
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 334 times.
695 if(loopcnt > 0)
16248 361 --loopcnt;
16249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 else if (loopcnt == 0)
16250 {
16251
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 128 times.
334 if((misc%dmisc6)==0)
16252 {
16253
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (dmisc21 > 0) loopcnt=-dmisc21;
16254 128 else loopcnt=dmisc7;
16255 128 }
16256 334 }
16257 else if (loopcnt == -1) loopcnt=dmisc7;
16258 else ++loopcnt;
16259
16260
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
695 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
16261 695 }
16262 else
16263 {
16264 loopcnt = 0;
16265 misc = 1;
16266 }
16267 695 }
16268 61552 }
16269
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk4 > 0) --clk4;
16270
16271
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk6 < 0)
16272 {
16273 if (dmisc5 == 1 || dmisc5 == 3)
16274 {
16275 if (get_qr(qr_NEWENEMYTILES))
16276 {
16277 if (clk7 <= 0 || clk6 != -16) ++clk6;
16278 if (clk6 == 0) o_tile=d->e_tile;
16279 else
16280 {
16281 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
16282 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
16283 }
16284 }
16285 else clk6 = 0;
16286 }
16287 }
16288
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 else if (dmisc19) ++clk6;
16289
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk5 < 0) ++clk5;
16290
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 else if (dmisc19) ++clk5;
16291
16292
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
61552 if (clk7 > 0 && clk6 >= -16) --clk7;
16293
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk6 > 0) clk7 = 0;
16294
16295
2/2
✓ Branch 0 taken 244144 times.
✓ Branch 1 taken 61552 times.
305696 for(int32_t i=index+1; i<index+flycnt+1; i++)
16296 {
16297 //outside ring
16298
2/2
✓ Branch 0 taken 243720 times.
✓ Branch 1 taken 424 times.
244144 if(!adjusted)
16299 {
16300
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 152 times.
424 if(get_qr(qr_NEWENEMYTILES))
16301 {
16302 272 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
16303 272 enemy *s = ((enemy*)guys.spr(i));
16304 272 s->parent_script_UID = this->script_UID;
16305 272 }
16306 else
16307 {
16308 152 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16309 152 enemy *s = ((enemy*)guys.spr(i));
16310 152 s->parent_script_UID = this->script_UID;
16311 }
16312
16313 424 ((enemy*)guys.spr(i))->cs=dmisc9;
16314 424 ((enemy*)guys.spr(i))->hp=dmisc3;
16315 424 }
16316
16317
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 243783 times.
244144 if(((enemy*)guys.spr(i))->hp <= 0)
16318 {
16319
2/2
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 361 times.
1655 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16320 {
16321 1294 guys.swap(j,j+1);
16322 1294 }
16323
16324
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
361 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
16325 361 }
16326 else
16327 {
16328 243783 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16329
1/2
✓ Branch 0 taken 243783 times.
✗ Branch 1 not taken.
243783 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
16330
16331
2/2
✓ Branch 0 taken 86967 times.
✓ Branch 1 taken 156816 times.
243783 if(!dmisc4) //Big Ring
16332 {
16333 //maybe playing_field_offset here?
16334
2/2
✓ Branch 0 taken 84872 times.
✓ Branch 1 taken 71944 times.
156816 if(loopcnt>0)
16335 {
16336
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16337
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16338 84872 }
16339 else
16340 {
16341 71944 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16342 71944 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16343 }
16344
16345 156816 temp_x=guys.spr(i)->x;
16346 156816 temp_y=guys.spr(i)->y;
16347 156816 }
16348 else //Oval
16349 {
16350 86967 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16351 86967 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16352
16353
2/2
✓ Branch 0 taken 50142 times.
✓ Branch 1 taken 36825 times.
86967 if(loopcnt>0)
16354 {
16355 50142 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16356
1/2
✓ Branch 0 taken 50142 times.
✗ Branch 1 not taken.
50142 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
16357 50142 }
16358 else
16359 {
16360 36825 guys.spr(i)->x = circle_x;
16361 36825 guys.spr(i)->y = circle_y;
16362 }
16363
16364 86967 temp_x=circle_x;
16365 86967 temp_y=circle_y;
16366 }
16367
16368 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16369 243783 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16370
16371
4/4
✓ Branch 0 taken 46216 times.
✓ Branch 1 taken 197567 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30939 times.
243783 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16372 {
16373 30939 guys.spr(i)->dir=l_down;
16374 30939 }
16375
4/4
✓ Branch 0 taken 46264 times.
✓ Branch 1 taken 166580 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30987 times.
212844 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16376 {
16377 30987 guys.spr(i)->dir=left;
16378 30987 }
16379
4/4
✓ Branch 0 taken 45998 times.
✓ Branch 1 taken 135859 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30721 times.
181857 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16380 {
16381 30721 guys.spr(i)->dir=l_up;
16382 30721 }
16383
4/4
✓ Branch 0 taken 45644 times.
✓ Branch 1 taken 105492 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30367 times.
151136 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16384 {
16385 30367 guys.spr(i)->dir=up;
16386 30367 }
16387
4/4
✓ Branch 0 taken 45419 times.
✓ Branch 1 taken 75350 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30142 times.
120769 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16388 {
16389 30142 guys.spr(i)->dir=r_up;
16390 30142 }
16391
4/4
✓ Branch 0 taken 45271 times.
✓ Branch 1 taken 45356 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 29994 times.
90627 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16392 {
16393 29994 guys.spr(i)->dir=right;
16394 29994 }
16395
4/4
✓ Branch 0 taken 45354 times.
✓ Branch 1 taken 15279 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30077 times.
60633 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16396 {
16397 30077 guys.spr(i)->dir=r_down;
16398 30077 }
16399 else
16400 {
16401 30556 guys.spr(i)->dir=down;
16402 }
16403
16404 243783 guys.spr(i)->x += x;
16405 243783 guys.spr(i)->y += y;
16406 }
16407 244144 }
16408
16409
7/22
✓ Branch 0 taken 39936 times.
✓ Branch 1 taken 21616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39936 times.
✓ Branch 4 taken 5813 times.
✓ Branch 5 taken 15803 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5813 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15803 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
61552 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
16410 {
16411 15803 int timeneeded = 48;
16412 15803 int patbreath = (zc_oldrand()%50+50);
16413
2/2
✓ Branch 0 taken 11961 times.
✓ Branch 1 taken 3842 times.
15803 if ((patbreath % 4) == 0) ++patbreath;
16414
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratBREATH)
16415 {
16416 timeneeded = 48 + patbreath;
16417 }
16418
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratSTREAM)
16419 {
16420 timeneeded = 48 + 96;
16421 }
16422
4/14
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15803 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 133 times.
✓ Branch 11 taken 133 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
15803 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
16423
2/2
✓ Branch 0 taken 15803 times.
✓ Branch 1 taken 133 times.
15936 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
16424
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15936 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16425 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
16426 133 && (clk6 >= 0) //if not in the middle of firing...
16427 133 && clk6 >= dmisc19) //if over the set cooldown between shots...
16428
2/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
133 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
16429 {
16430
1/3
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
133 switch(dmisc28)
16431 {
16432 case patratSTREAM:
16433 {
16434 clk7 = 97;
16435 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16436 else clk6 = 0;
16437 break;
16438 }
16439 case patratBREATH:
16440 {
16441 clk7 = patbreath;
16442 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16443 else clk6 = 0;
16444 break;
16445 }
16446 default:
16447 {
16448
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16449 {
16450 clk6 = -48;
16451 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16452 }
16453 else
16454 {
16455 133 clk6 = 0;
16456
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16457 133 FirePatraWeapon();
16458 }
16459 133 break;
16460 }
16461 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16462 133 }
16463
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (clk6 < 0)
16464 {
16465 switch(dmisc28)
16466 {
16467 case patratSTREAM:
16468 {
16469 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
16470 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16471 break;
16472 }
16473 case patratBREATH:
16474 {
16475 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
16476 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16477 break;
16478 }
16479 default:
16480 {
16481 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
16482 {
16483 FirePatraWeapon();
16484 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16485 }
16486 break;
16487 }
16488 }
16489 }
16490 15803 }
16491
16492 61552 int randattempts = 0;
16493 61552 int randeye = 0;
16494
2/2
✓ Branch 0 taken 44950 times.
✓ Branch 1 taken 16602 times.
61552 if (flycnt2 > 0)
16495 {
16496 16602 do
16497 {
16498
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16602 times.
✓ Branch 2 taken 15935 times.
✓ Branch 3 taken 667 times.
16602 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
16499 16602 randeye += (index + flycnt + 1);
16500 16602 ++randattempts;
16501
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
16502 16602 }
16503 61552 bool dofire = false;
16504
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (dmisc20)
16505 {
16506 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16507 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
16508 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
16509 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
16510 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
16511 {
16512 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16513 {
16514 if (clk5 >= dmisc19)
16515 {
16516 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16517 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
16518 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
16519 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
16520 || dmisc18 == -1)
16521 dofire = true;
16522 }
16523 }
16524 }
16525 }
16526
2/2
✓ Branch 0 taken 44950 times.
✓ Branch 1 taken 16602 times.
61552 if(flycnt2)
16527 {
16528
2/2
✓ Branch 0 taken 119975 times.
✓ Branch 1 taken 16602 times.
136577 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
16529 {
16530
2/2
✓ Branch 0 taken 119887 times.
✓ Branch 1 taken 88 times.
119975 if(!adjusted)
16531 {
16532 88 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
16533
16534
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(get_qr(qr_NEWENEMYTILES))
16535 {
16536
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16537 {
16538
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
88 switch(dmisc5)
16539 {
16540 // Center eye shoots projectiles; make room for its firing tiles
16541 case 1:
16542 case 3:
16543 48 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
16544 48 break;
16545
16546 // Center eyes does not shoot; use tiles two rows below for inner eyes.
16547 default:
16548 case 2:
16549 40 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
16550 40 break;
16551 }
16552 88 }
16553 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
16554 88 }
16555 else
16556 {
16557 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16558 }
16559
16560 88 ((enemy*)guys.spr(i))->cs=dmisc9;
16561
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
16562 88 }
16563
16564
2/2
✓ Branch 0 taken 94136 times.
✓ Branch 1 taken 25839 times.
119975 if(flycnt>0)
16565 {
16566 94136 ((enemy*)guys.spr(i))->superman=true;
16567 94136 }
16568 else
16569 {
16570 25839 ((enemy*)guys.spr(i))->superman=false;
16571 }
16572
16573
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 119903 times.
119975 if(((enemy*)guys.spr(i))->hp <= 0)
16574 {
16575
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 72 times.
216 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16576 {
16577 144 guys.swap(j,j+1);
16578 144 }
16579
16580
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
72 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
16581 72 }
16582 else
16583 {
16584 119903 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16585
1/2
✓ Branch 0 taken 119903 times.
✗ Branch 1 not taken.
119903 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
16586
16587
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 112644 times.
119903 if(dmisc4==0)
16588 {
16589
2/2
✓ Branch 0 taken 58268 times.
✓ Branch 1 taken 54376 times.
112644 if(loopcnt>0)
16590 {
16591
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16592
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16593 58268 }
16594 else
16595 {
16596 54376 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16597 54376 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16598 }
16599
16600 112644 temp_x=guys.spr(i)->x;
16601 112644 temp_y=guys.spr(i)->y;
16602 112644 }
16603 else
16604 {
16605 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16606 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16607
16608
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
16609 {
16610 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16611
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
16612 3965 }
16613 else
16614 {
16615 3294 guys.spr(i)->x = circle_x;
16616 3294 guys.spr(i)->y = circle_y;
16617 }
16618
16619 7259 temp_x=circle_x;
16620 7259 temp_y=circle_y;
16621 }
16622
16623 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16624 119903 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16625
16626
4/4
✓ Branch 0 taken 22203 times.
✓ Branch 1 taken 97700 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14941 times.
119903 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16627 {
16628 14941 guys.spr(i)->dir=l_down;
16629 14941 }
16630
4/4
✓ Branch 0 taken 22190 times.
✓ Branch 1 taken 82772 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14928 times.
104962 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16631 {
16632 14928 guys.spr(i)->dir=left;
16633 14928 }
16634
4/4
✓ Branch 0 taken 22199 times.
✓ Branch 1 taken 67835 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14937 times.
90034 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16635 {
16636 14937 guys.spr(i)->dir=l_up;
16637 14937 }
16638
4/4
✓ Branch 0 taken 22258 times.
✓ Branch 1 taken 52839 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14996 times.
75097 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16639 {
16640 14996 guys.spr(i)->dir=up;
16641 14996 }
16642
4/4
✓ Branch 0 taken 22303 times.
✓ Branch 1 taken 37798 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15041 times.
60101 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16643 {
16644 15041 guys.spr(i)->dir=r_up;
16645 15041 }
16646
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 22763 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
45060 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16647 {
16648 15035 guys.spr(i)->dir=right;
16649 15035 }
16650
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 7728 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
30025 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16651 {
16652 15035 guys.spr(i)->dir=r_down;
16653 15035 }
16654 else
16655 {
16656 14990 guys.spr(i)->dir=down;
16657 }
16658
16659 119903 guys.spr(i)->x += x;
16660 119903 guys.spr(i)->y = y-guys.spr(i)->y;
16661
16662
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 119903 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81826 times.
✓ Branch 5 taken 38077 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 81826 times.
119903 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
16663 {
16664 /*
16665 if(!(zc_oldrand()&127))
16666 {
16667 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
16668 sfx(wpnsfx(wpn),pan(int32_t(x)));
16669 }
16670 */
16671
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38077 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
16672 {
16673 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
16674 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16675 {
16676 if (dmisc5 == 3)
16677 {
16678 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16679 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
16680 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
16681 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16682 }
16683 else
16684 {
16685 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16686 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16687 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
16688 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16689 }
16690 }
16691 else
16692 {
16693 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16694 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
16695 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
16696 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16697 }
16698 }
16699
4/6
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38077 times.
✓ Branch 4 taken 38077 times.
✓ Branch 5 taken 38077 times.
38077 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
16700
1/2
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
38077 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
16701
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
16702 {
16703
1/5
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
38077 switch(dmisc20) //Patra Attack Patterns
16704 {
16705 case 4: //Single one rapidfires
16706 {
16707 if (dofire && i == randeye)
16708 {
16709 ((esPatra*)guys.spr(i))->clk5 = -16;
16710 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
16711 ((esPatra*)guys.spr(i))->clk4 = 96;
16712 clk5 = -3;
16713 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16714 }
16715 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
16716 {
16717 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16718 sfx(wpnsfx(wpn),pan(int32_t(x)));
16719 }
16720 break;
16721 }
16722 case 3: //Ring
16723 {
16724 if (dofire)
16725 {
16726 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16727 {
16728 ((esPatra*)guys.spr(i))->clk5 = -48;
16729 clk5 = -48;
16730 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16731 }
16732 else
16733 {
16734 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16735 sfx(wpnsfx(wpn),pan(int32_t(x)));
16736 int32_t m=Ewpns.Count()-1;
16737 weapon *ew = (weapon*)(Ewpns.spr(m));
16738
16739 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16740 ((esPatra*)guys.spr(i))->clk5 = 0;
16741 clk5 = 0;
16742 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16743 }
16744 }
16745 if (((esPatra*)guys.spr(i))->clk5 == -16)
16746 {
16747 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16748 sfx(wpnsfx(wpn),pan(int32_t(x)));
16749 int32_t m=Ewpns.Count()-1;
16750 weapon *ew = (weapon*)(Ewpns.spr(m));
16751
16752 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16753 }
16754 break;
16755 }
16756 case 2: //one after another
16757 {
16758 if (dofire)
16759 {
16760 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
16761 clk5 = -48 - (12*flycnt2);
16762 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16763 }
16764 if (((esPatra*)guys.spr(i))->clk5 == -16)
16765 {
16766 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16767 sfx(wpnsfx(wpn),pan(int32_t(x)));
16768 }
16769 break;
16770 }
16771 case 1: //random one eye
16772 {
16773 if (dofire && i == randeye)
16774 {
16775 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16776 {
16777 ((esPatra*)guys.spr(i))->clk5 = -48;
16778 clk5 = -48;
16779 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16780 }
16781 else
16782 {
16783 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16784 sfx(wpnsfx(wpn),pan(int32_t(x)));
16785 ((esPatra*)guys.spr(i))->clk5 = 0;
16786 clk5 = 0;
16787 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16788 }
16789 }
16790 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16791 {
16792 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16793 sfx(wpnsfx(wpn),pan(int32_t(x)));
16794 }
16795 break;
16796 }
16797 default: //old behavior, all eyes can fire any time
16798 {
16799
3/8
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 292 times.
✓ Branch 5 taken 292 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16800
3/6
✓ Branch 0 taken 38077 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 292 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16801
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16802 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16803 {
16804
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16805 {
16806 ((esPatra*)guys.spr(i))->clk5 = -48;
16807 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16808 }
16809 else
16810 {
16811 292 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16812 292 sfx(wpnsfx(wpn),pan(int32_t(x)));
16813 292 ((esPatra*)guys.spr(i))->clk5 = 0;
16814
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16815 }
16816 292 }
16817
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16818 {
16819 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16820 sfx(wpnsfx(wpn),pan(int32_t(x)));
16821 }
16822 38077 break;
16823 }
16824 }
16825 38077 }
16826 38077 }
16827
16828 }
16829 119975 }
16830 16602 }
16831
16832 61552 adjusted=true;
16833 61552 return enemy::animate(index);
16834 62362 }
16835
16836 133 void ePatra::FirePatraWeapon()
16837 { //.707
16838 133 int32_t xoff = 0;
16839 133 int32_t yoff = 0;
16840
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
16841 {
16842 xoff += (hit_width/2)-8;
16843 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
16844 }
16845
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
16846 {
16847 yoff += (hit_height/2)-8;
16848 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
16849 }
16850 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
16851
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
133 switch (dmisc28)
16852 {
16853 case patrat8SHOT: //Fire Wizzrobe
16854 case patrat4SHOTDIAG:
16855 case patrat4SHOTRAND:
16856 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16857 {
16858 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16859 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16860 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16861 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16862
16863 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16864 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16865 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16866 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16867
16868 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16869 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16870 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16871 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16872
16873 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16875 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16876 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16877
16878 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16879 }
16880
16881 [[fallthrough]];
16882 case patrat4SHOTCARD: //Stalfos 3
16883 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16884 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16885 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16886 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16887 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16888 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16889 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16890 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16891 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16892 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16893 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16894 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16895 break;
16896
16897 default:
16898 133 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16899
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16900 133 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16901
3/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16902
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 133 times.
133 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16903 {
16904 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16905 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16906 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16907 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16908 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16909 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16910 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16911 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16912 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16913 {
16914 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16915 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16916 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16917 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16918 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16919 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16920 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16921 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16922 }
16923 }
16924 133 break;
16925
16926 }
16927 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
16928 //+0.46364761
16929 //11.80
16930 133 }
16931
16932 124918 void ePatra::draw(BITMAP *dest)
16933 {
16934 124918 tile=o_tile;
16935 124918 update_enemy_frame();
16936 124918 enemy::draw(dest);
16937 124918 }
16938
16939 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16940 {
16941 int32_t ret = enemy::defend(wpnId, power, edef);
16942
16943 if(ret < 0 && (flycnt||flycnt2))
16944 return 0;
16945
16946 return ret;
16947 }
16948
16949 908 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16950 {
16951 908 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16952
16953
6/6
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 397 times.
✓ Branch 3 taken 408 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 145 times.
908 if(ret < 0 && (flycnt||flycnt2))
16954 660 return 0;
16955
16956 248 return ret;
16957 908 }
16958
16959 1024 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16960 512 {
16961 //cs=8;
16962 512 item_set=0;
16963 512 misc=clk;
16964 512 clk4 = 0;
16965 512 clk5 = 0;
16966 512 clk = -((misc*21)>>1)-1;
16967
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16968 512 hit_width=12;
16969 512 hit_height=12;
16970 512 hxofs=2;
16971 512 hyofs=2;
16972 512 extend = 0;
16973 512 txsz = 1;
16974 512 tysz = 1;
16975 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16976 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16977 int32_t prntSIZEflags = prntenemy->SIZEflags;
16978 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16979 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16980 // al_trace("Enemy txsz:%i\n", txsz);
16981 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16982 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16983 else
16984 hxsz=12;
16985 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16986 else
16987 hysz=12;
16988 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16989 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16990 else
16991 hxofs=2;
16992 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16993 else hyofs=2;
16994 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16995 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16996 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16997 {
16998 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16999 }
17000
17001 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
17002 */
17003 512 mainguy=count_enemy=false;
17004 512 bgsfx=-1;
17005 //o_tile=0;
17006 512 flags &= (~guy_neverret);
17007 512 deadsfx = WAV_EDEAD;
17008 512 hitsfx = WAV_EHIT;
17009 512 isCore = false;
17010 512 }
17011
17012 372279 bool esPatra::animate(int32_t index)
17013 {
17014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 372279 times.
372279 if(switch_hooked) return enemy::animate(index);
17015
2/2
✓ Branch 0 taken 7866 times.
✓ Branch 1 taken 364413 times.
372279 if(dying)
17016 7866 return Dead(index);
17017
17018 364413 return enemy::animate(index);
17019 372279 }
17020
17021 747310 void esPatra::draw(BITMAP *dest)
17022 {
17023
2/2
✓ Branch 0 taken 544720 times.
✓ Branch 1 taken 202590 times.
747310 if(get_qr(qr_NEWENEMYTILES))
17024 {
17025 544720 tile = o_tile+(clk&3);
17026
17027
8/9
✓ Branch 0 taken 67770 times.
✓ Branch 1 taken 69066 times.
✓ Branch 2 taken 67800 times.
✓ Branch 3 taken 67996 times.
✓ Branch 4 taken 67484 times.
✓ Branch 5 taken 68044 times.
✓ Branch 6 taken 68474 times.
✓ Branch 7 taken 68086 times.
✗ Branch 8 not taken.
544720 switch(dir) //directions get screwed up after 8. *shrug*
17028 {
17029 case up: //u
17030 67770 flip=0;
17031 67770 break;
17032
17033 case down: //d
17034 69066 flip=0;
17035 69066 tile+=4;
17036 69066 break;
17037
17038 case left: //l
17039 67800 flip=0;
17040 67800 tile+=8;
17041 67800 break;
17042
17043 case right: //r
17044 67996 flip=0;
17045 67996 tile+=12;
17046 67996 break;
17047
17048 case l_up: //ul
17049 67484 flip=0;
17050 67484 tile+=20;
17051 67484 break;
17052
17053 case r_up: //ur
17054 68044 flip=0;
17055 68044 tile+=24;
17056 68044 break;
17057
17058 case l_down: //dl
17059 68474 flip=0;
17060 68474 tile+=28;
17061 68474 break;
17062
17063 case r_down: //dr
17064 68086 flip=0;
17065 68086 tile+=32;
17066 68086 break;
17067 }
17068 544720 }
17069 else
17070 {
17071 202590 tile = o_tile+((clk&2)>>1);
17072 }
17073
17074
2/2
✓ Branch 0 taken 38248 times.
✓ Branch 1 taken 709062 times.
747310 if(clk>=0)
17075 709062 enemy::draw(dest);
17076 747310 }
17077
17078
17079 3 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
17080 3 {
17081 3 adjusted=false;
17082
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dir=(zc_oldrand()&7)+8;
17083
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 step=0.25;
17084 3 clk4 = 0;
17085 3 clk5 = 0;
17086 //flycnt=6; flycnt2=0;
17087 3 flycnt=dmisc1;
17088 3 flycnt2=0; // PatraBS doesn't have inner rings!
17089 3 loopcnt=0;
17090
17091 3 SIZEflags = d->SIZEflags;
17092
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17093 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17094 // al_trace("Enemy txsz:%i\n", txsz);
17095
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17096
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
17097 3 else hit_width = 32;
17098
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
17099
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17101 3 else hxofs=-8;
17102
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17103 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
17105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17106 {
17107 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
17108 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
17109 }
17110
17111
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
17112
17113
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
17114
17115 //nets+4480;
17116 3 }
17117
17118 1862 bool ePatraBS::animate(int32_t index)
17119 {
17120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862 times.
1862 if(switch_hooked) return enemy::animate(index);
17121
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1808 times.
1862 if(dying)
17122 54 return Dead(index);
17123
17124
2/2
✓ Branch 0 taken 1366 times.
✓ Branch 1 taken 442 times.
1808 if(clk==0)
17125 {
17126 442 removearmos(x,y,ffcactivated);
17127 442 }
17128
17129 1808 variable_walk_8(rate,homing,hrate,spw_floater);
17130
17131
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 19 times.
1808 if(++clk2>90)
17132 {
17133 19 clk2=0;
17134
17135
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 if(loopcnt)
17136 12 --loopcnt;
17137 else
17138 {
17139
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if((misc%dmisc6)==0)
17140 4 loopcnt=dmisc7;
17141 }
17142
17143 19 ++misc;
17144 19 }
17145
17146 // double size=1;;
17147
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 1808 times.
6263 for(int32_t i=index+1; i<index+flycnt+1; i++)
17148 {
17149
2/2
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 18 times.
4455 if(!adjusted)
17150 {
17151 18 ((enemy*)guys.spr(i))->hp=dmisc3;
17152
17153
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(get_qr(qr_NEWENEMYTILES))
17154 {
17155 18 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
17156 18 }
17157 else
17158 {
17159 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
17160 }
17161
17162 18 ((enemy*)guys.spr(i))->cs = dmisc9;
17163 18 }
17164
17165
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4437 times.
4455 if(((enemy*)guys.spr(i))->hp <= 0)
17166 {
17167
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 18 times.
44 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
17168 {
17169 26 guys.swap(j,j+1);
17170 26 }
17171
17172 18 --flycnt;
17173 18 }
17174 else
17175 {
17176 4437 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
17177
1/2
✓ Branch 0 taken 4437 times.
✗ Branch 1 not taken.
4437 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
17178 4437 temp_x = zc::math::Cos(a2+PI/2)*45;
17179 4437 temp_y = -zc::math::Sin(a2+PI/2)*45;
17180
17181
2/2
✓ Branch 0 taken 2305 times.
✓ Branch 1 taken 2132 times.
4437 if(loopcnt>0)
17182 {
17183 2305 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
17184
1/2
✓ Branch 0 taken 2305 times.
✗ Branch 1 not taken.
2305 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
17185 2305 }
17186 else
17187 {
17188 2132 guys.spr(i)->x = temp_x;
17189 2132 guys.spr(i)->y = temp_y;
17190 }
17191
17192 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17193 4437 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
17194
17195
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 3576 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 551 times.
4437 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17196 {
17197 551 guys.spr(i)->dir=l_down;
17198 551 }
17199
4/4
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 3042 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 534 times.
3886 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17200 {
17201 534 guys.spr(i)->dir=left;
17202 534 }
17203
4/4
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 2520 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 522 times.
3352 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17204 {
17205 522 guys.spr(i)->dir=l_up;
17206 522 }
17207
4/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 1956 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 564 times.
2830 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17208 {
17209 564 guys.spr(i)->dir=up;
17210 564 }
17211
4/4
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1411 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 545 times.
2266 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17212 {
17213 545 guys.spr(i)->dir=r_up;
17214 545 }
17215
4/4
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 849 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 562 times.
1721 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17216 {
17217 562 guys.spr(i)->dir=right;
17218 562 }
17219
4/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 554 times.
1159 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17220 {
17221 554 guys.spr(i)->dir=r_down;
17222 554 }
17223 else
17224 {
17225 605 guys.spr(i)->dir=down;
17226 }
17227
17228 4437 guys.spr(i)->x += x;
17229 4437 guys.spr(i)->y += y;
17230 }
17231 4455 }
17232
17233 1808 adjusted=true;
17234 1808 return enemy::animate(index);
17235 1862 }
17236
17237 3724 void ePatraBS::draw(BITMAP *dest)
17238 {
17239 3724 tile=o_tile;
17240
17241
1/2
✓ Branch 0 taken 3724 times.
✗ Branch 1 not taken.
3724 if(get_qr(qr_NEWENEMYTILES))
17242 {
17243 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17244 3724 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
17245
17246
4/4
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 3320 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 102 times.
3724 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17247 {
17248 102 lookat=l_down;
17249 102 }
17250
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 3010 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 310 times.
3622 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17251 {
17252 310 lookat=down;
17253 310 }
17254
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 2058 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 952 times.
3312 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17255 {
17256 952 lookat=r_down;
17257 952 }
17258
4/4
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 1686 times.
2360 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17259 {
17260 1686 lookat=right;
17261 1686 }
17262
4/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 180 times.
674 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17263 {
17264 180 lookat=r_up;
17265 180 }
17266
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17267 {
17268 lookat=up;
17269 }
17270
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 302 times.
494 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17271 {
17272 lookat=l_up;
17273 }
17274 else
17275 {
17276 494 lookat=left;
17277 }
17278
17279
6/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 494 times.
✓ Branch 4 taken 1686 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 102 times.
✓ Branch 8 taken 952 times.
3724 switch(lookat) //directions get screwed up after 8. *shrug*
17280 {
17281 case up: //u
17282 flip=0;
17283 break;
17284
17285 case down: //d
17286 310 flip=0;
17287 310 tile+=8;
17288 310 break;
17289
17290 case left: //l
17291 494 flip=0;
17292 494 tile+=40;
17293 494 break;
17294
17295 case right: //r
17296 1686 flip=0;
17297 1686 tile+=48;
17298 1686 break;
17299
17300 case l_up: //ul
17301 flip=0;
17302 tile+=80;
17303 break;
17304
17305 case r_up: //ur
17306 180 flip=0;
17307 180 tile+=88;
17308 180 break;
17309
17310 case l_down: //dl
17311 102 flip=0;
17312 102 tile+=120;
17313 102 break;
17314
17315 case r_down: //dr
17316 952 flip=0;
17317 952 tile+=128;
17318 952 break;
17319 }
17320
17321 3724 tile+=(2*(clk&3));
17322 3724 xofs-=8;
17323 3724 yofs-=8;
17324 3724 drawblock(dest,15);
17325 3724 xofs+=8;
17326 3724 yofs+=8;
17327 3724 }
17328 else
17329 {
17330 flip=(clk&1);
17331 xofs-=8;
17332 yofs-=8;
17333 enemy::draw(dest);
17334 xofs+=16;
17335 enemy::draw(dest);
17336 yofs+=16;
17337 enemy::draw(dest);
17338 xofs-=16;
17339 enemy::draw(dest);
17340 xofs+=8;
17341 yofs-=8;
17342 }
17343 3724 }
17344
17345 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
17346 {
17347 int32_t ret = enemy::defend(wpnId, power, edef);
17348
17349 if(ret < 0 && (flycnt||flycnt2))
17350 return 0;
17351
17352 return ret;
17353 }
17354
17355 25 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
17356 {
17357 25 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
17358
17359
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
25 if(ret < 0 && (flycnt||flycnt2))
17360 19 return 0;
17361
17362 6 return ret;
17363 25 }
17364
17365 36 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
17366 18 {
17367 //cs=csBOSS;
17368 18 item_set=0;
17369 18 misc=clk;
17370 18 clk = -((misc*21)>>1)-1;
17371 18 clk4 = 0;
17372 18 clk5 = 0;
17373
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
17374 18 int32_t prntSIZEflags = prntenemy->SIZEflags;
17375
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17376 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17377 // al_trace("Enemy txsz:%i\n", txsz);
17378
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
17379
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
17380 18 else hit_width=16;
17381
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
17382 18 else hit_height=16;
17383
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
17384
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
17385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
17386 18 else hyofs=2;
17387 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17388
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
17389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17390 {
17391 yofs = (int32_t)prntenemy->yofs;
17392 }
17393
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17394
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
17395
17396 18 bgsfx=-1;
17397 18 mainguy=count_enemy=false;
17398 18 deadsfx = WAV_EDEAD;
17399 18 hitsfx = WAV_EHIT;
17400 18 flags &= ~guy_neverret;
17401 18 isCore = false;
17402 18 }
17403
17404 4790 bool esPatraBS::animate(int32_t index)
17405 {
17406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4790 times.
4790 if(switch_hooked) return enemy::animate(index);
17407
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 4466 times.
4790 if(dying)
17408 324 return Dead(index);
17409
17410 4466 return enemy::animate(index);
17411 4790 }
17412
17413 9580 void esPatraBS::draw(BITMAP *dest)
17414 {
17415 9580 tile=o_tile;
17416
17417
1/2
✓ Branch 0 taken 9580 times.
✗ Branch 1 not taken.
9580 if(get_qr(qr_NEWENEMYTILES))
17418 {
17419
8/9
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 1326 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 1254 times.
✓ Branch 4 taken 1080 times.
✓ Branch 5 taken 1238 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 1180 times.
✗ Branch 8 not taken.
9580 switch(dir) //directions get screwed up after 8. *shrug*
17420 {
17421 case up: //u
17422 1280 flip=0;
17423 1280 break;
17424
17425 case down: //d
17426 1326 flip=0;
17427 1326 tile+=4;
17428 1326 break;
17429
17430 case left: //l
17431 1076 flip=0;
17432 1076 tile+=8;
17433 1076 break;
17434
17435 case right: //r
17436 1254 flip=0;
17437 1254 tile+=12;
17438 1254 break;
17439
17440 case l_up: //ul
17441 1080 flip=0;
17442 1080 tile+=20;
17443 1080 break;
17444
17445 case r_up: //ur
17446 1238 flip=0;
17447 1238 tile+=24;
17448 1238 break;
17449
17450 case l_down: //dl
17451 1146 flip=0;
17452 1146 tile+=28;
17453 1146 break;
17454
17455 case r_down: //dr
17456 1180 flip=0;
17457 1180 tile+=32;
17458 1180 break;
17459 }
17460
17461 9580 tile += ((clk&6)>>1);
17462 9580 }
17463 else
17464 {
17465 tile += (clk&4)?1:0;
17466 }
17467
17468
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 8608 times.
9580 if(clk>=0)
17469 8608 enemy::draw(dest);
17470 9580 }
17471
17472
17473 /**********************************/
17474 /********** Misc Code ***********/
17475 /**********************************/
17476
17477 162470 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
17478 {
17479
4/6
✓ Branch 0 taken 122104 times.
✓ Branch 1 taken 40366 times.
✓ Branch 2 taken 122104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 122104 times.
✗ Branch 5 not taken.
162470 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
17480
4/8
✓ Branch 0 taken 162470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162470 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162470 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 162470 times.
✗ Branch 7 not taken.
162470 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
17481
1/2
✓ Branch 0 taken 162470 times.
✗ Branch 1 not taken.
162470 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
17482 162470 }
17483
17484 36428 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
17485 {
17486 // Kludge
17487
4/8
✓ Branch 0 taken 36428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36428 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36428 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36428 times.
✗ Branch 7 not taken.
36428 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
17488 36428 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
17489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36428 times.
36428 delete w;
17490 36428 return ret;
17491 }
17492
17493 4228 void enemy_scored(int32_t index)
17494 {
17495 4228 ((enemy*)guys.spr(index))->scored=true;
17496 4228 }
17497
17498 1440 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
17499 {
17500
6/10
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115 times.
✓ Branch 7 taken 1325 times.
✓ Branch 8 taken 1440 times.
✗ Branch 9 not taken.
1440 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
17501
3/6
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 672 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1440 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
17502 {
17503 g->o_tile = parentscr->guytile;
17504 if(g->o_tile != 0)
17505 g->flags &= ~guy_invisible;
17506 g->cs = parentscr->guycs;
17507 }
17508 1440 guys.add(g);
17509 1440 }
17510
17511 22137 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17512 {
17513
4/8
✓ Branch 0 taken 22137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22137 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22137 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22137 times.
✗ Branch 7 not taken.
22137 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
17514 22137 items.add(i);
17515 22137 }
17516
17517 80 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
17518 {
17519
5/10
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 80 times.
✗ Branch 9 not taken.
80 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
17520 80 items.add(i);
17521 80 }
17522
17523 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17524 {
17525 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
17526 items.add(i);
17527 }
17528
17529 79 void kill_em_all()
17530 {
17531
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 79 times.
375 for(int32_t i=0; i<guys.Count(); i++)
17532 {
17533 296 enemy *e = ((enemy*)guys.spr(i));
17534
17535
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
296 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17536
17537 271 e->kickbucket();
17538 271 }
17539 79 }
17540
17541 bool can_kill_em_all()
17542 {
17543 for(int32_t i=0; i<guys.Count(); i++)
17544 {
17545 enemy *e = ((enemy*)guys.spr(i));
17546
17547 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17548 if(e->superman) continue;
17549 return true;
17550 }
17551 return false;
17552 }
17553
17554 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
17555 // For Hero's hit detection. Don't count them if they are stunned or are guys.
17556 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17557 {
17558 for(int32_t i=0; i<guys.Count(); i++)
17559 {
17560 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17561 {
17562 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
17563 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
17564 {
17565 return i;
17566 }
17567 }
17568 }
17569
17570 return -1;
17571 }
17572
17573 6675046 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17574 {
17575
4/4
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 6666352 times.
✓ Branch 2 taken 19149455 times.
✓ Branch 3 taken 6657762 times.
25807217 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
17576 {
17577
2/2
✓ Branch 0 taken 17284 times.
✓ Branch 1 taken 19132171 times.
19149455 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17578 {
17579 17284 return i;
17580 }
17581 19132171 }
17582
17583 6657762 return -1;
17584 6675046 }
17585
17586 // For Hero's hit detection. Count them if they are dying.
17587 27398 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17588 {
17589 27398 enemy *e = (enemy*)guys.spr(index);
17590
3/4
✓ Branch 0 taken 27398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14844 times.
✓ Branch 3 taken 12554 times.
27398 if(!e || e->hp > 0)
17591 14844 return -1;
17592
17593 12554 bool d = e->dying;
17594 12554 int32_t hc = e->hclk;
17595 12554 e->dying = false;
17596 12554 e->hclk = 0;
17597 12554 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
17598 12554 e->dying = d;
17599 12554 e->hclk = hc;
17600
17601
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 12433 times.
12554 return hit ? index : -1;
17602 27398 }
17603
17604 7288205 bool hasMainGuy()
17605 {
17606
2/2
✓ Branch 0 taken 8741411 times.
✓ Branch 1 taken 2591743 times.
11333154 for(int32_t i=0; i<guys.Count(); i++)
17607 {
17608
2/2
✓ Branch 0 taken 4696462 times.
✓ Branch 1 taken 4044949 times.
8741411 if(((enemy*)guys.spr(i))->mainguy)
17609 {
17610 4696462 return true;
17611 }
17612 4044949 }
17613
17614 2591743 return false;
17615 7288205 }
17616
17617 51 void EatHero(int32_t index)
17618 {
17619 51 ((eStalfos*)guys.spr(index))->eathero();
17620 51 }
17621
17622 3 void GrabHero(int32_t index)
17623 {
17624 3 ((eWallM*)guys.spr(index))->grabhero();
17625 3 }
17626
17627 292 bool CarryHero()
17628 {
17629
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 for(int32_t i=0; i<guys.Count(); i++)
17630 {
17631
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 355 times.
891 if(((guy*)(guys.spr(i)))->family==eeWALLM)
17632 {
17633
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 63 times.
355 if(((eWallM*)guys.spr(i))->hashero)
17634 {
17635 292 Hero.x=guys.spr(i)->x;
17636 292 Hero.y=guys.spr(i)->y;
17637 292 return ((eWallM*)guys.spr(i))->misc > 0;
17638 }
17639 63 }
17640
17641 // Like Likes currently can't carry Hero.
17642 /*
17643 if(((guy*)(guys.spr(i)))->family==eeLIKE)
17644 {
17645 if(((eLikeLike*)guys.spr(i))->hashero)
17646 {
17647 Hero.x=guys.spr(i)->x;
17648 Hero.y=guys.spr(i)->y;
17649 return (true);
17650 }
17651 }*/
17652 599 }
17653
17654 return false;
17655 292 }
17656
17657 // Move item with guy
17658 void movefairy(zfix &x,zfix &y,int32_t misc)
17659 {
17660 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17661
17662 if(i!=-1)
17663 {
17664 x = guys.spr(i)->x;
17665 y = guys.spr(i)->y;
17666 }
17667 }
17668
17669 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17670 void movefairy2(zfix x,zfix y,int32_t misc)
17671 {
17672 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17673
17674 if(i!=-1)
17675 {
17676 guys.spr(i)->x = x;
17677 guys.spr(i)->y = y;
17678 }
17679 }// Move item with guy
17680
17681 33988 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
17682 {
17683 33988 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17684
17685
1/2
✓ Branch 0 taken 33988 times.
✗ Branch 1 not taken.
33988 if(fairy)
17686 {
17687 33988 x = fairy->x;
17688 33988 y = fairy->y;
17689 33988 }
17690 33988 }
17691
17692 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17693 void movefairynew2(zfix x,zfix y, item const &itemfairy)
17694 {
17695 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17696
17697 if(fairy)
17698 {
17699 fairy->x = x;
17700 fairy->y = y;
17701 }
17702 }
17703
17704 void killfairy(int32_t misc)
17705 {
17706 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17707 guys.del(i);
17708 }
17709
17710 int32_t getGuyIndex(const int32_t eid)
17711 {
17712 for(word i = 0; i < guys.Count(); i++)
17713 {
17714 if(guys.spr(i)->getUID() == eid)
17715 return i;
17716 }
17717
17718 return -1;
17719 }
17720
17721 void killfairynew(item const &itemfairy)
17722 {
17723 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17724 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
17725 }
17726
17727 //Should probably change this to return an 'enemy*', null on failure -Em
17728 13284 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
17729 {
17730 13284 return addenemy(x,y,0,id,clk);
17731 }
17732
17733 868 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
17734 {
17735 868 return addchild(x,y,0,id,clk, parent_scriptUID);
17736 }
17737
17738 893 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
17739 {
17740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if(id <= 0) return 0;
17741
17742 893 int32_t ret = 0;
17743 893 sprite *e=NULL;
17744 893 al_trace("Adding child\n");
17745
17746
5/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 857 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
893 switch(guysbuf[id&0xFFF].family)
17747 {
17748 //Fixme: possible enemy memory leak. (minor)
17749 case eeWALK:
17750
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17751 16 break;
17752
17753 case eeLEV:
17754 e = new eLeever((zfix)x,(zfix)y,id,clk);
17755 break;
17756
17757 case eeTEK:
17758 e = new eTektite((zfix)x,(zfix)y,id,clk);
17759 break;
17760
17761 case eePEAHAT:
17762 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17763 break;
17764
17765 case eeZORA:
17766 e = new eZora((zfix)x,(zfix)y,id,clk);
17767 break;
17768
17769 case eeGHINI:
17770 e = new eGhini((zfix)x,(zfix)y,id,clk);
17771 break;
17772
17773 case eeKEESE:
17774
3/6
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 857 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 857 times.
✗ Branch 5 not taken.
857 e = new eKeese((zfix)x,(zfix)y,id,clk);
17775 857 break;
17776
17777 case eeWIZZ:
17778
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17779 15 break;
17780
17781 case eePROJECTILE:
17782 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17783 break;
17784
17785 case eeWALLM:
17786 e = new eWallM((zfix)x,(zfix)y,id,clk);
17787 break;
17788
17789 case eeAQUA:
17790 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17791 break;
17792
17793 case eeMOLD:
17794 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17795 break;
17796
17797 case eeMANHAN:
17798
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17799 1 break;
17800
17801 case eeGLEEOK:
17802 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17803 break;
17804
17805 case eeGHOMA:
17806 e = new eGohma((zfix)x,(zfix)y,id,clk);
17807 break;
17808
17809 case eeLANM:
17810 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
17811 break;
17812
17813 case eeGANON:
17814 e = new eGanon((zfix)x,(zfix)y,id,clk);
17815 break;
17816
17817 case eeFAIRY:
17818 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17819 break;
17820
17821 case eeFIRE:
17822 e = new eFire((zfix)x,(zfix)y,id,clk);
17823 break;
17824
17825 case eeOTHER:
17826 e = new eOther((zfix)x,(zfix)y,id,clk);
17827 break;
17828
17829
17830 case eeSCRIPT01:
17831 case eeSCRIPT02:
17832 case eeSCRIPT03:
17833 case eeSCRIPT04:
17834 case eeSCRIPT05:
17835 case eeSCRIPT06:
17836 case eeSCRIPT07:
17837 case eeSCRIPT08:
17838 case eeSCRIPT09:
17839 case eeSCRIPT10:
17840 case eeSCRIPT11:
17841 case eeSCRIPT12:
17842 case eeSCRIPT13:
17843 case eeSCRIPT14:
17844 case eeSCRIPT15:
17845 case eeSCRIPT16:
17846 case eeSCRIPT17:
17847 case eeSCRIPT18:
17848 case eeSCRIPT19:
17849 case eeSCRIPT20:
17850 {
17851 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17852 {
17853 e = new eScript((zfix)x,(zfix)y,id,clk);
17854 break;
17855 }
17856 else return 0;
17857 }
17858
17859 case eeFFRIENDLY01:
17860 case eeFFRIENDLY02:
17861 case eeFFRIENDLY03:
17862 case eeFFRIENDLY04:
17863 case eeFFRIENDLY05:
17864 case eeFFRIENDLY06:
17865 case eeFFRIENDLY07:
17866 case eeFFRIENDLY08:
17867 case eeFFRIENDLY09:
17868 case eeFFRIENDLY10:
17869 {
17870 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17871 {
17872 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17873 }
17874 else return 0;
17875
17876 }
17877
17878 case eeSPINTILE:
17879 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17880 break;
17881
17882 // and these enemies use the misc10/misc2 value
17883 case eeROCK:
17884 {
17885 switch(guysbuf[id&0xFFF].misc10)
17886 {
17887 case 1:
17888 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17889 break;
17890
17891 case 0:
17892 default:
17893 e = new eRock((zfix)x,(zfix)y,id,clk);
17894 break;
17895 }
17896
17897 break;
17898 }
17899
17900 case eeTRAP:
17901 {
17902 switch(guysbuf[id&0xFFF].misc2)
17903 {
17904 case 1:
17905 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17906 break;
17907
17908 case 0:
17909 default:
17910 e = new eTrap((zfix)x,(zfix)y,id,clk);
17911 break;
17912 }
17913
17914 break;
17915 }
17916
17917 case eeDONGO:
17918 {
17919 switch(guysbuf[id&0xFFF].misc10)
17920 {
17921 case 1:
17922 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17923 break;
17924
17925 case 0:
17926 default:
17927 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17928 break;
17929 }
17930
17931 break;
17932 }
17933
17934 case eeDIG:
17935 {
17936
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].misc10)
17937 {
17938 case 1:
17939 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17940 break;
17941
17942 4 case 0:
17943 default:
17944
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17945 4 break;
17946 }
17947
17948 4 break;
17949 }
17950
17951 case eePATRA:
17952 {
17953 switch(guysbuf[id&0xFFF].misc10)
17954 {
17955 case 1:
17956 if (get_qr(qr_HARDCODED_BS_PATRA))
17957 {
17958 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17959 break;
17960 }
17961 [[fallthrough]];
17962 case 0:
17963 default:
17964 e = new ePatra((zfix)x,(zfix)y,id,clk);
17965 break;
17966 }
17967
17968 break;
17969 }
17970
17971 case eeGUY:
17972 {
17973 switch(guysbuf[id&0xFFF].misc10)
17974 {
17975 case 1:
17976 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17977 break;
17978
17979 case 0:
17980 default:
17981 e = new eNPC((zfix)x,(zfix)y,id,clk);
17982 break;
17983 }
17984
17985 break;
17986 }
17987
17988 case eeNONE:
17989 if(guysbuf[id&0xFFF].misc10 ==1)
17990 {
17991 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17992 break;
17993 break;
17994 }
17995 [[fallthrough]];
17996 default:
17997
17998 return 0;
17999 }
18000
18001 893 ret++; // Made one enemy.
18002
18003
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if(z && canfall(id))
18004 {
18005 e->z = (zfix)z;
18006 }
18007
18008
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 ((enemy*)e)->ceiling = (z && canfall(id));
18009 893 ((enemy*)e)->parent_script_UID = parent_scriptUID;
18010 //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID);
18011 //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID);
18012 //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18013 //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18014
18015
18016
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if(!guys.add(e))
18017 {
18018 return 0;
18019 }
18020
18021 // add segments of segmented enemies
18022 893 int32_t c=0;
18023
18024
2/6
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 switch(guysbuf[id&0xFFF].family)
18025 {
18026 case eeMOLD:
18027 {
18028 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18029 id &= 0xFFF;
18030
18031 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18032 {
18033 //christ this is messy -DD
18034 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18035
18036 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18037 {
18038 al_trace("Moldorm segment %d could not be created!\n",i+1);
18039
18040 for(int32_t j=0; j<i+1; j++)
18041 guys.del(guys.Count()-1);
18042
18043 return 0;
18044 }
18045
18046 if(i>0)
18047 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18048
18049 ret++;
18050 }
18051
18052 break;
18053 }
18054
18055 case eeLANM:
18056 {
18057 id &= 0xFFF;
18058 int32_t shft = guysbuf[id].misc2;
18059 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18060
18061 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18062 {
18063 al_trace("Lanmola segment 1 could not be created!\n");
18064 guys.del(guys.Count()-1);
18065 return 0;
18066 }
18067
18068 ret++;
18069
18070 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18071 {
18072 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18073 {
18074 al_trace("Lanmola segment %d could not be created!\n",i+1);
18075
18076 for(int32_t j=0; j<i+1; j++)
18077 guys.del(guys.Count()-1);
18078
18079 return 0;
18080 }
18081
18082 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18083 ret++;
18084 }
18085 }
18086 break;
18087
18088 case eeMANHAN:
18089 1 id &= 0xFFF;
18090
18091
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18092 {
18093
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18094 {
18095 al_trace("Manhandla head %d could not be created!\n",i+1);
18096
18097 for(int32_t j=0; j<i+1; j++)
18098 {
18099 guys.del(guys.Count()-1);
18100 }
18101
18102 return 0;
18103 }
18104
18105 4 ret++;
18106 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18107 4 }
18108
18109 1 break;
18110
18111 case eeGLEEOK:
18112 {
18113 id &= 0xFFF;
18114
18115 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18116 {
18117 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
18118 {
18119 al_trace("Gleeok head %d could not be created!\n",i+1);
18120
18121 for(int32_t j=0; j<i+1; j++)
18122 {
18123 guys.del(guys.Count()-1);
18124 }
18125
18126 return false;
18127 }
18128
18129 c-=guysbuf[id].misc4;
18130 ret++;
18131 }
18132 }
18133 break;
18134
18135
18136 case eePATRA:
18137 {
18138 id &= 0xFFF;
18139 int32_t outeyes = 0;
18140
18141 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18142 {
18143 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18144 {
18145 al_trace("Patra outer eye %d could not be created!\n",i+1);
18146
18147 for(int32_t j=0; j<i+1; j++)
18148 guys.del(guys.Count()-1);
18149
18150 return 0;
18151 }
18152 else
18153 outeyes++;
18154
18155 ret++;
18156 }
18157
18158 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18159 {
18160 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18161 {
18162 al_trace("Patra inner eye %d could not be created!\n",i+1);
18163
18164 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18165 guys.del(guys.Count()-1);
18166
18167 return 0;
18168 }
18169
18170 ret++;
18171 }
18172
18173 break;
18174 }
18175 }
18176
18177 893 return ret;
18178 893 }
18179
18180 // Returns number of enemies/segments created
18181 52936 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
18182 {
18183 //zprint2("addenemy id is: %d\n", (id&0xFFF));
18184 52936 int32_t realid = id&0xFFF;
18185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52936 times.
52936 if( realid > MAXGUYS )
18186 {
18187 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()");
18188 return 0;
18189 }
18190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52936 times.
52936 if(id <= 0) return 0;
18191
18192 52936 int32_t ret = 0;
18193 52936 sprite *e=NULL;
18194
18195
27/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26744 times.
✓ Branch 4 taken 1694 times.
✓ Branch 5 taken 2941 times.
✓ Branch 6 taken 1048 times.
✓ Branch 7 taken 1605 times.
✓ Branch 8 taken 140 times.
✓ Branch 9 taken 5764 times.
✓ Branch 10 taken 2135 times.
✓ Branch 11 taken 2257 times.
✓ Branch 12 taken 523 times.
✓ Branch 13 taken 76 times.
✓ Branch 14 taken 94 times.
✓ Branch 15 taken 58 times.
✓ Branch 16 taken 94 times.
✓ Branch 17 taken 55 times.
✓ Branch 18 taken 239 times.
✓ Branch 19 taken 10 times.
✓ Branch 20 taken 413 times.
✓ Branch 21 taken 374 times.
✓ Branch 22 taken 4900 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 256 times.
✓ Branch 25 taken 889 times.
✓ Branch 26 taken 141 times.
✓ Branch 27 taken 246 times.
✓ Branch 28 taken 56 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 90 times.
52936 switch(guysbuf[id&0xFFF].family)
18196 {
18197 //Fixme: possible enemy memory leak. (minor)
18198 case eeWALK:
18199
3/6
✓ Branch 0 taken 26744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26744 times.
✗ Branch 5 not taken.
26744 e = new eStalfos((zfix)x,(zfix)y,id,clk);
18200 26744 break;
18201
18202 case eeLEV:
18203
3/6
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1694 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1694 times.
✗ Branch 5 not taken.
1694 e = new eLeever((zfix)x,(zfix)y,id,clk);
18204 1694 break;
18205
18206 case eeTEK:
18207
3/6
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2941 times.
✗ Branch 5 not taken.
2941 e = new eTektite((zfix)x,(zfix)y,id,clk);
18208 2941 break;
18209
18210 case eePEAHAT:
18211
3/6
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1048 times.
✗ Branch 5 not taken.
1048 e = new ePeahat((zfix)x,(zfix)y,id,clk);
18212 1048 break;
18213
18214 case eeZORA:
18215
3/6
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1605 times.
✗ Branch 5 not taken.
1605 e = new eZora((zfix)x,(zfix)y,id,clk);
18216 1605 break;
18217
18218 case eeGHINI:
18219
3/6
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
140 e = new eGhini((zfix)x,(zfix)y,id,clk);
18220 140 break;
18221
18222 case eeKEESE:
18223
3/6
✓ Branch 0 taken 5764 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5764 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5764 times.
✗ Branch 5 not taken.
5764 e = new eKeese((zfix)x,(zfix)y,id,clk);
18224 5764 break;
18225
18226 case eeWIZZ:
18227
3/6
✓ Branch 0 taken 2135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2135 times.
✗ Branch 5 not taken.
2135 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
18228 2135 break;
18229
18230 case eePROJECTILE:
18231
3/6
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2257 times.
✗ Branch 5 not taken.
2257 e = new eProjectile((zfix)x,(zfix)y,id,clk);
18232 2257 break;
18233
18234 case eeWALLM:
18235
3/6
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 523 times.
✗ Branch 5 not taken.
523 e = new eWallM((zfix)x,(zfix)y,id,clk);
18236 523 break;
18237
18238 case eeAQUA:
18239
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
18240 76 break;
18241
18242 case eeMOLD:
18243
6/12
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
✓ Branch 6 taken 94 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
94 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18244 94 break;
18245
18246 case eeMANHAN:
18247
3/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58 times.
✗ Branch 5 not taken.
58 e = new eManhandla((zfix)x,(zfix)y,id,clk);
18248 58 break;
18249
18250 case eeGLEEOK:
18251
7/12
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
✓ Branch 6 taken 79 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
94 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18252 94 break;
18253
18254 case eeGHOMA:
18255
3/6
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
55 e = new eGohma((zfix)x,(zfix)y,id,clk);
18256 55 break;
18257
18258 case eeLANM:
18259
6/12
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 239 times.
✓ Branch 6 taken 239 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 239 times.
✓ Branch 10 taken 239 times.
✗ Branch 11 not taken.
239 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
18260 239 break;
18261
18262 case eeGANON:
18263
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 e = new eGanon((zfix)x,(zfix)y,id,clk);
18264 10 break;
18265
18266 case eeFAIRY:
18267
3/6
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
413 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
18268 413 break;
18269
18270 case eeFIRE:
18271
3/6
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374 times.
✗ Branch 5 not taken.
374 e = new eFire((zfix)x,(zfix)y,id,clk);
18272 374 break;
18273
18274 case eeOTHER:
18275
3/6
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4900 times.
✗ Branch 5 not taken.
4900 e = new eOther((zfix)x,(zfix)y,id,clk);
18276 4900 break;
18277
18278
18279 case eeSCRIPT01:
18280 case eeSCRIPT02:
18281 case eeSCRIPT03:
18282 case eeSCRIPT04:
18283 case eeSCRIPT05:
18284 case eeSCRIPT06:
18285 case eeSCRIPT07:
18286 case eeSCRIPT08:
18287 case eeSCRIPT09:
18288 case eeSCRIPT10:
18289 case eeSCRIPT11:
18290 case eeSCRIPT12:
18291 case eeSCRIPT13:
18292 case eeSCRIPT14:
18293 case eeSCRIPT15:
18294 case eeSCRIPT16:
18295 case eeSCRIPT17:
18296 case eeSCRIPT18:
18297 case eeSCRIPT19:
18298 case eeSCRIPT20:
18299 {
18300 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18301 {
18302 e = new eScript((zfix)x,(zfix)y,id,clk);
18303 break;
18304 }
18305 else return 0;
18306 }
18307
18308 case eeFFRIENDLY01:
18309 case eeFFRIENDLY02:
18310 case eeFFRIENDLY03:
18311 case eeFFRIENDLY04:
18312 case eeFFRIENDLY05:
18313 case eeFFRIENDLY06:
18314 case eeFFRIENDLY07:
18315 case eeFFRIENDLY08:
18316 case eeFFRIENDLY09:
18317 case eeFFRIENDLY10:
18318 {
18319 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18320 {
18321 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
18322 }
18323 else return 0;
18324
18325 }
18326
18327 case eeSPINTILE:
18328
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
18329 94 break;
18330
18331 // and these enemies use the misc10/misc2 value
18332 case eeROCK:
18333 {
18334
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 226 times.
256 switch(guysbuf[id&0xFFF].misc10)
18335 {
18336 case 1:
18337
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
18338 30 break;
18339
18340 226 case 0:
18341 default:
18342
3/6
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 226 times.
✗ Branch 5 not taken.
226 e = new eRock((zfix)x,(zfix)y,id,clk);
18343 226 break;
18344 }
18345
18346 256 break;
18347 }
18348
18349 case eeTRAP:
18350 {
18351
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 742 times.
889 switch(guysbuf[id&0xFFF].misc2)
18352 {
18353 case 1:
18354
3/6
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147 times.
✗ Branch 5 not taken.
147 e = new eTrap2((zfix)x,(zfix)y,id,clk);
18355 147 break;
18356
18357 742 case 0:
18358 default:
18359
3/6
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 742 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 742 times.
✗ Branch 5 not taken.
742 e = new eTrap((zfix)x,(zfix)y,id,clk);
18360 742 break;
18361 }
18362
18363 889 break;
18364 }
18365
18366 case eeDONGO:
18367 {
18368
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 139 times.
141 switch(guysbuf[id&0xFFF].misc10)
18369 {
18370 case 1:
18371
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
18372 2 break;
18373
18374 139 case 0:
18375 default:
18376
3/6
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
139 e = new eDodongo((zfix)x,(zfix)y,id,clk);
18377 139 break;
18378 }
18379
18380 141 break;
18381 }
18382
18383 case eeDIG:
18384 {
18385
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 48 times.
246 switch(guysbuf[id&0xFFF].misc10)
18386 {
18387 case 1:
18388
3/6
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 198 times.
✗ Branch 5 not taken.
198 e = new eLilDig((zfix)x,(zfix)y,id,clk);
18389 198 break;
18390
18391 48 case 0:
18392 default:
18393
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eBigDig((zfix)x,(zfix)y,id,clk);
18394 48 break;
18395 }
18396
18397 246 break;
18398 }
18399
18400 case eePATRA:
18401 {
18402
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 3 times.
56 switch(guysbuf[id&0xFFF].misc10)
18403 {
18404 case 1:
18405
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (get_qr(qr_HARDCODED_BS_PATRA))
18406 {
18407
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
18408 3 break;
18409 }
18410 [[fallthrough]];
18411 53 case 0:
18412 default:
18413
3/6
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
53 e = new ePatra((zfix)x,(zfix)y,id,clk);
18414 53 break;
18415 }
18416
18417 56 break;
18418 }
18419
18420 case eeGUY:
18421 {
18422 switch(guysbuf[id&0xFFF].misc10)
18423 {
18424 case 1:
18425 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18426 break;
18427
18428 case 0:
18429 default:
18430 e = new eNPC((zfix)x,(zfix)y,id,clk);
18431 break;
18432 }
18433
18434 break;
18435 }
18436
18437 case eeNONE:
18438
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(guysbuf[id&0xFFF].misc10 ==1)
18439 {
18440
3/6
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
90 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18441 90 break;
18442 break;
18443 }
18444 [[fallthrough]];
18445 default:
18446
18447 return 0;
18448 }
18449
18450 52936 ret++; // Made one enemy.
18451
18452
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 52853 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
52936 if(z && canfall(id))
18453 {
18454 59 e->z = (zfix)z;
18455 59 }
18456
18457
2/2
✓ Branch 0 taken 52853 times.
✓ Branch 1 taken 83 times.
52936 ((enemy*)e)->ceiling = (z && canfall(id));
18458
18459
1/2
✓ Branch 0 taken 52936 times.
✗ Branch 1 not taken.
52936 if(!guys.add(e))
18460 {
18461 return 0;
18462 }
18463
18464 // add segments of segmented enemies
18465 52936 int32_t c=0;
18466
18467
6/6
✓ Branch 0 taken 52395 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 58 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 56 times.
52936 switch(guysbuf[id&0xFFF].family)
18468 {
18469 case eeMOLD:
18470 {
18471 94 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18472 94 id &= 0xFFF;
18473
18474
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 624 times.
✓ Branch 2 taken 624 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 624 times.
✓ Branch 6 taken 530 times.
✓ Branch 7 taken 94 times.
624 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18475 {
18476 //christ this is messy -DD
18477 530 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18478
18479
4/8
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 530 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 530 times.
✗ Branch 7 not taken.
530 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18480 {
18481 al_trace("Moldorm segment %d could not be created!\n",i+1);
18482
18483 for(int32_t j=0; j<i+1; j++)
18484 guys.del(guys.Count()-1);
18485
18486 return 0;
18487 }
18488
18489
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 436 times.
530 if(i>0)
18490 436 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18491
18492 530 ret++;
18493 530 }
18494
18495 94 break;
18496 }
18497
18498 case eeLANM:
18499 {
18500 239 id &= 0xFFF;
18501 239 int32_t shft = guysbuf[id].misc2;
18502 239 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18503
18504
4/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 239 times.
✗ Branch 7 not taken.
239 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18505 {
18506 al_trace("Lanmola segment 1 could not be created!\n");
18507 guys.del(guys.Count()-1);
18508 return 0;
18509 }
18510
18511 239 ret++;
18512
18513
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1250 times.
✓ Branch 2 taken 1250 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1250 times.
✓ Branch 6 taken 1011 times.
✓ Branch 7 taken 239 times.
1250 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18514 {
18515
4/8
✓ Branch 0 taken 1011 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1011 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1011 times.
✗ Branch 7 not taken.
1011 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18516 {
18517 al_trace("Lanmola segment %d could not be created!\n",i+1);
18518
18519 for(int32_t j=0; j<i+1; j++)
18520 guys.del(guys.Count()-1);
18521
18522 return 0;
18523 }
18524
18525 1011 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18526 1011 ret++;
18527 1011 }
18528 }
18529 239 break;
18530
18531 case eeMANHAN:
18532 58 id &= 0xFFF;
18533
18534
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 58 times.
322 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18535 {
18536
4/8
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 264 times.
✗ Branch 7 not taken.
264 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18537 {
18538 al_trace("Manhandla head %d could not be created!\n",i+1);
18539
18540 for(int32_t j=0; j<i+1; j++)
18541 {
18542 guys.del(guys.Count()-1);
18543 }
18544
18545 return 0;
18546 }
18547
18548 264 ret++;
18549 264 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18550 264 }
18551
18552 58 break;
18553
18554 case eeGLEEOK:
18555 {
18556 94 id &= 0xFFF;
18557 94 eGleeok* parent = (eGleeok*)e;
18558
18559
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 332 times.
✓ Branch 6 taken 268 times.
✓ Branch 7 taken 94 times.
362 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18560 {
18561
3/6
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
268 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
18562
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if(!guys.add(head))
18563 {
18564 al_trace("Gleeok head %d could not be created!\n",i+1);
18565
18566 for(int32_t j=0; j<i+1; j++)
18567 {
18568 guys.del(guys.Count()-1);
18569 }
18570
18571 return false;
18572 }
18573
18574 268 head->necktile=parent->necktile;
18575 268 head->dummy_int[1]=parent->necktile;
18576
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 73 times.
268 if(get_qr(qr_NEWENEMYTILES))
18577 {
18578 195 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
18579 195 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
18580 195 }
18581 else
18582 {
18583 73 head->dummy_int[2]=parent->necktile+1; //connected head tile
18584 73 head->dummy_int[3]=parent->necktile+2; //flying head tile
18585 }
18586 268 head->tile = head->dummy_int[2];
18587
18588 268 c-=guysbuf[id].misc4;
18589 268 ret++;
18590 268 }
18591 }
18592 94 break;
18593
18594
18595 case eePATRA:
18596 {
18597 56 id &= 0xFFF;
18598 56 int32_t outeyes = 0;
18599
18600
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 498 times.
✓ Branch 2 taken 442 times.
✓ Branch 3 taken 56 times.
498 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18601 {
18602
10/22
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 424 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 424 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 424 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 424 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
442 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18603 {
18604 al_trace("Patra outer eye %d could not be created!\n",i+1);
18605
18606 for(int32_t j=0; j<i+1; j++)
18607 guys.del(guys.Count()-1);
18608
18609 return 0;
18610 }
18611 else
18612 442 outeyes++;
18613
18614 442 ret++;
18615 442 }
18616
18617
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 56 times.
144 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18618 {
18619
4/8
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
88 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18620 {
18621 al_trace("Patra inner eye %d could not be created!\n",i+1);
18622
18623 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18624 guys.del(guys.Count()-1);
18625
18626 return 0;
18627 }
18628
18629 88 ret++;
18630 88 }
18631
18632 56 break;
18633 }
18634 }
18635
18636 52936 return ret;
18637 52936 }
18638
18639 1251618 bool isjumper(int32_t id)
18640 {
18641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1251618 times.
1251618 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18642 {
18643 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()");
18644 return false;
18645 }
18646
3/3
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1151282 times.
✓ Branch 2 taken 100332 times.
1251618 switch(guysbuf[id&0xFFF].family)
18647 {
18648 case eeROCK:
18649 case eeTEK:
18650 4 return true;
18651
18652 case eeWALK:
18653
3/4
✓ Branch 0 taken 100332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 88067 times.
100332 if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true;
18654 88067 }
18655
18656 1239349 return false;
18657 1251618 }
18658
18659
18660 115481 bool isfixedtogrid(int32_t id)
18661 {
18662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115481 times.
115481 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18663 {
18664 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()");
18665 return false;
18666 }
18667
1/2
✓ Branch 0 taken 115481 times.
✗ Branch 1 not taken.
115481 switch(guysbuf[id&0xFFF].family)
18668 {
18669 case eeWALK:
18670 case eeLEV:
18671 case eeZORA:
18672 case eeDONGO:
18673 case eeGANON:
18674 case eeROCK:
18675 case eeGLEEOK:
18676 case eeAQUA:
18677 case eeLANM:
18678 return true;
18679 }
18680
18681 115481 return false;
18682 115481 }
18683
18684 // Can't fall, can have Z value.
18685 30363108 bool isflier(int32_t id)
18686 {
18687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30363108 times.
30363108 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18688 {
18689 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()");
18690 return false;
18691 }
18692
2/2
✓ Branch 0 taken 27055941 times.
✓ Branch 1 taken 3307167 times.
30363108 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
18693 {
18694 case eePEAHAT:
18695 case eeKEESE:
18696 case eePATRA:
18697 case eeFAIRY:
18698 case eeGHINI:
18699
18700 // Could theoretically have their Z set by a script
18701 case eeFIRE:
18702 3307167 return true;
18703 break;
18704 }
18705
18706 27055941 return false;
18707 30363108 }
18708
18709 // Can't have Z position
18710 2341162 bool never_in_air(int32_t id)
18711 {
18712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2341162 times.
2341162 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18713 {
18714 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()");
18715 return false;
18716 }
18717
2/2
✓ Branch 0 taken 2331614 times.
✓ Branch 1 taken 9548 times.
2341162 switch(guysbuf[id&0xFFF].family)
18718 {
18719 case eeMANHAN:
18720 case eeMOLD:
18721 case eeLANM:
18722 case eeGLEEOK:
18723 case eeZORA:
18724 case eeLEV:
18725 case eeAQUA:
18726 case eeROCK:
18727 case eeGANON:
18728 case eeTRAP:
18729 case eePROJECTILE:
18730 case eeSPINTILE:
18731 9548 return true;
18732 }
18733
18734 2331614 return false;
18735 2341162 }
18736
18737 1370668 bool canfall(int32_t id)
18738 {
18739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1370668 times.
1370668 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18740 {
18741 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()");
18742 return false;
18743 }
18744
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1370642 times.
✓ Branch 2 taken 26 times.
1370668 switch(guysbuf[id&0xFFF].family)
18745 {
18746 case eeGUY:
18747 {
18748
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(id < eOCTO1S)
18749 26 return false;
18750
18751 switch(guysbuf[id&0xFFF].misc10)
18752 {
18753 case 1:
18754 case 2:
18755 return true;
18756
18757 case 0:
18758 case 3:
18759 default:
18760 return false;
18761 }
18762
18763 case eeGHOMA:
18764 case eeDIG:
18765 return false;
18766 }
18767 }
18768
18769
18770
4/4
✓ Branch 0 taken 1362208 times.
✓ Branch 1 taken 8434 times.
✓ Branch 2 taken 110590 times.
✓ Branch 3 taken 1251618 times.
1370642 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18771 1370668 }
18772
18773 31454090 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18774 {
18775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31454090 times.
31454090 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18776 {
18777 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()");
18778 return false;
18779 }
18780 //Z_scripterrlog("canfall family is %d:\n", family);
18781 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false");
18782 //if ( family == eeFIRE && id >= eSTART )
18783 //{
18784 // Z_scripterrlog("eeFire\n");
18785 // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z
18786 //}
18787
18788 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18789
18790
3/3
✓ Branch 0 taken 195032 times.
✓ Branch 1 taken 30218229 times.
✓ Branch 2 taken 1040829 times.
31454090 switch(guysbuf[id&0xFFF].family)
18791 {
18792 case eeGUY:
18793 {
18794
1/2
✓ Branch 0 taken 1040829 times.
✗ Branch 1 not taken.
1040829 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18795 1040829 return false;
18796
18797 switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z
18798 {
18799 case 1:
18800 case 2:
18801 return true;
18802
18803 case 0:
18804 case 3:
18805 default:
18806 return false;
18807 }
18808
18809 case eeGHOMA:
18810 case eeDIG:
18811 195032 return false;
18812 }
18813 }
18814
18815
2/2
✓ Branch 0 taken 21662519 times.
✓ Branch 1 taken 8555710 times.
30218229 if(!checkgrav) return true;
18816 21662519 return (moveflags & FLAG_OBEYS_GRAV);
18817
18818 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18819 // {
18820 // if ( moveflags & FLAG_OBEYS_GRAV ) return true;
18821 // else return false;
18822 // }
18823 // else
18824 // {
18825 // return (moveflags & FLAG_OBEYS_GRAV);
18826 // }
18827 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18828 31454090 }
18829
18830 758 void addfires()
18831 {
18832
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 336 times.
758 if(!get_qr(qr_NOGUYFIRES))
18833 {
18834 336 int32_t bs = get_qr(qr_BSZELDA);
18835 336 addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr);
18836 336 addguy(bs?176:168,64,gFIRE,-18,false,nullptr);
18837 336 }
18838 758 }
18839
18840 16279 void loadguys()
18841 {
18842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16279 times.
16279 if(loaded_guys)
18843 return;
18844
18845 16279 loaded_guys=true;
18846
18847 16279 byte Guy=0;
18848 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18849 // Else use mITEM and ipONETIME
18850 16279 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
18851 16279 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
18852
18853 16279 repaircharge=0;
18854 16279 adjustmagic=false;
18855 16279 learnslash=false;
18856
18857
2/2
✓ Branch 0 taken 48837 times.
✓ Branch 1 taken 16279 times.
65116 for(int32_t i=0; i<3; i++)
18858 {
18859 48837 prices[i]=0;
18860 48837 }
18861
18862 16279 hasitem=0;
18863
18864 16279 mapscr* guyscr = tmpscr;
18865
4/4
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 15600 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 339 times.
16279 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
18866 {
18867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if(DMaps[currdmap].flags&dmfCAVES)
18868 {
18869 339 Guy=tmpscr[1].guy;
18870 339 guyscr = tmpscr+1;
18871 339 }
18872 339 }
18873 else
18874 {
18875 15940 Guy=tmpscr->guy;
18876
18877
4/4
✓ Branch 0 taken 15600 times.
✓ Branch 1 taken 340 times.
✓ Branch 2 taken 9437 times.
✓ Branch 3 taken 6163 times.
15940 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
18878 6163 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
18879 }
18880
18881 16279 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18882 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18883
4/4
✓ Branch 0 taken 2858 times.
✓ Branch 1 taken 13421 times.
✓ Branch 2 taken 2081 times.
✓ Branch 3 taken 777 times.
16279 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
18884 {
18885
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 768 times.
777 if(tmpscr->room==rZELDA)
18886 {
18887 9 addguy(120,72,Guy,-15,true,guyscr);
18888 9 guys.spr(0)->hxofs=1000;
18889 9 addenemy(128,96,eFIRE,-15);
18890 9 addenemy(112,96,eFIRE,-15);
18891 9 addenemy(96,120,eFIRE,-15);
18892 9 addenemy(144,120,eFIRE,-15);
18893 9 return;
18894 }
18895
18896
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
1536 bool ffire = oldguy
18897
2/2
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 10 times.
768 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18898 : (guyscr->roomflags&RFL_GUYFIRES);
18899
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 758 times.
768 if(ffire)
18900 758 addfires();
18901
18902
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 335 times.
768 if(currscr>=128)
18903
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
347 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
18904 12 Guy=0;
18905
18906
4/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 647 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 23 times.
768 switch(tmpscr->room)
18907 {
18908 case rSP_ITEM:
18909 case rGRUMBLE:
18910 case rBOMBS:
18911 case rARROWS:
18912 case rSWINDLE:
18913 case rMUPGRADE:
18914 case rLEARNSLASH:
18915 case rTAKEONE:
18916
8/8
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 33 times.
97 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18917 28 Guy=0;
18918
18919 117 break;
18920
18921 case rREPAIR:
18922 if (get_qr(qr_OLD_DOORREPAIR)) break;
18923 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18924 Guy=0;
18925
18926 break;
18927 case rRP_HC:
18928 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18929 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18930 Guy=0;
18931
18932 break;
18933 case rMONEY:
18934
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18935 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18936 Guy=0;
18937
18938 break;
18939
18940 case rTRIFORCE:
18941 {
18942 23 int32_t tc = TriforceCount();
18943
18944
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 12 times.
23 if(get_qr(qr_4TRI))
18945 {
18946
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18947 10 Guy=0;
18948 9 }
18949 else
18950 {
18951
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18952 12 Guy=0;
18953 }
18954 }
18955 21 break;
18956 }
18957
18958
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 708 times.
766 if(Guy)
18959 {
18960
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 698 times.
708 if(ffire)
18961 698 blockpath=true;
18962
18963
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 385 times.
708 if(currscr<128)
18964 385 sfx(WAV_SCALE);
18965
18966
4/4
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 382 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 323 times.
708 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr);
18967 708 Hero.Freeze();
18968 708 }
18969 766 }
18970
3/6
✓ Branch 0 taken 15502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 15451 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15502 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18971 {
18972 51 sfx(WAV_SCALE);
18973 51 addguy(120,62,Guy,-14,false,guyscr);
18974 51 }
18975
18976 16268 loaditem();
18977
18978 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18979 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18980
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 16258 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
16268 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
18981 {
18982 //setmapflag();
18983
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 8 times.
88 for(int32_t i=0; i<10; i++)
18984 80 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18985 8 }
18986 16277 }
18987
18988 16284 void loaditem()
18989 {
18990 16284 byte Item = 0;
18991
18992
2/2
✓ Branch 0 taken 15605 times.
✓ Branch 1 taken 679 times.
16284 if(currscr<128)
18993 {
18994 15605 Item=tmpscr->item;
18995
18996
4/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 14807 times.
✓ Branch 2 taken 14230 times.
✓ Branch 3 taken 1375 times.
15605 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
18997 {
18998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1375 times.
1375 if(tmpscr->flags8&fSECRETITEM)
18999 hasitem=8;
19000
2/2
✓ Branch 0 taken 629 times.
✓ Branch 1 taken 746 times.
1375 else if(tmpscr->flags&fITEM)
19001 629 hasitem=1;
19002
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 712 times.
746 else if(tmpscr->enemyflags&efCARRYITEM)
19003 34 hasitem=4; // Will be set to 2 by roaming_item
19004 else
19005
2/4
✓ Branch 0 taken 712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 712 times.
✗ Branch 3 not taken.
1424 items.add(new item((zfix)tmpscr->itemx,
19006
6/12
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 709 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 712 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 712 times.
✗ Branch 11 not taken.
712 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
19007
6/10
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 709 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 709 times.
✗ Branch 9 not taken.
712 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
19008
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 650 times.
712 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
19009 712 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19010 1375 }
19011 15605 }
19012
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 else if(!(DMaps[currdmap].flags&dmfCAVES))
19013 {
19014
4/6
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 336 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
341 if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
19015
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 230 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 109 times.
340 && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
19016 {
19017 110 Item=tmpscr[1].catchall;
19018
19019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(Item)
19020
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
220 items.add(new item((zfix)tmpscr->itemx,
19021
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 110 times.
✗ Branch 11 not taken.
110 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
19022
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
110 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
19023 110 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19024 110 }
19025 340 }
19026 16284 }
19027
19028 539 void never_return(int32_t index)
19029 {
19030
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 130 times.
539 if(!get_qr(qr_KILLALL))
19031 130 goto doit;
19032
19033
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 201 times.
1541 for(int32_t i=0; i<guys.Count(); i++)
19034
4/4
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 826 times.
✓ Branch 2 taken 208 times.
✓ Branch 3 taken 306 times.
1340 if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index)
19035 {
19036 208 goto dontdoit;
19037 201 }
19038
19039 doit:
19040 331 setmapflag(mNEVERRET);
19041 dontdoit:
19042 539 return;
19043 }
19044
19045 36942 bool slowguy(int32_t id)
19046 {
19047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36942 times.
36942 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19048 {
19049 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()");
19050 return false;
19051 }
19052 //return (guysbuf[id].step<100);
19053
2/2
✓ Branch 0 taken 31379 times.
✓ Branch 1 taken 5563 times.
36942 switch(id)
19054 {
19055 case eOCTO1S:
19056 case eOCTO2S:
19057 case eOCTO1F:
19058 case eOCTO2F:
19059 case eLEV1:
19060 case eLEV2:
19061 case eROCK:
19062 case eBOULDER:
19063 5563 return true;
19064 }
19065
19066 31379 return false;
19067 36942 }
19068
19069 41699 bool ok2add(int32_t id)
19070 {
19071
2/4
✓ Branch 0 taken 41699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41699 times.
41699 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
19072 {
19073 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()");
19074 return false;
19075 }
19076
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 41291 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 218 times.
41699 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret))
19077 218 return false;
19078
19079
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41326 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 92 times.
41481 switch(guysbuf[id].family)
19080 {
19081 // I added a special case for shooters because having traps on the same screen
19082 // was preventing them from spawning due to TMPNORET. This means they will
19083 // never stay dead, though, so it may not be the best solution. - Saf
19084 case eePROJECTILE:
19085 63 return true;
19086
19087
19088 case eeDIG:
19089 {
19090
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 47 times.
92 switch(guysbuf[id].misc10)
19091 {
19092 case 1:
19093
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 if(!get_qr(qr_NOTMPNORET))
19094 13 return !getmapflag(mTMPNORET);
19095
19096 32 return true;
19097
19098 47 case 0:
19099 default:
19100 47 return true;
19101 }
19102 }
19103 case eeGANON:
19104 case eeTRAP:
19105 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
19106 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
19107 [[fallthrough]];
19108 default:
19109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41326 times.
41326 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
19110 41326 break;
19111 }
19112
19113
2/2
✓ Branch 0 taken 14322 times.
✓ Branch 1 taken 27004 times.
41326 if(!get_qr(qr_NOTMPNORET))
19114 27004 return !getmapflag(mTMPNORET);
19115
19116 14322 return true;
19117 41699 }
19118
19119 402634 void activate_fireball_statue(int32_t pos)
19120 {
19121
3/4
✓ Branch 0 taken 113289 times.
✓ Branch 1 taken 289345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113289 times.
402634 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
19122 {
19123 289345 return;
19124 }
19125
19126 113289 int32_t cx=-1000, cy=-1000;
19127 113289 int32_t x = (pos&15)<<4;
19128 113289 int32_t y = pos&0xF0;
19129
19130 113289 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19131
19132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113289 times.
113289 if(!isfixedtogrid(statueID))
19133 {
19134
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 112292 times.
113289 if(ctype==cL_STATUE)
19135 {
19136 997 cx=x+4;
19137 997 cy=y+7;
19138 997 }
19139
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 111276 times.
112292 else if(ctype==cR_STATUE)
19140 {
19141 1016 cx=x-8;
19142 1016 cy=y-1;
19143 1016 }
19144
2/2
✓ Branch 0 taken 111097 times.
✓ Branch 1 taken 179 times.
111276 else if(ctype==cC_STATUE)
19145 {
19146 179 cx=x;
19147 179 cy=y;
19148 179 }
19149 113289 }
19150 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
19151 {
19152 cx=x;
19153 cy=y;
19154 }
19155
19156
2/2
✓ Branch 0 taken 111097 times.
✓ Branch 1 taken 2192 times.
113289 if(cx!=-1000) // No point creating it if this is false
19157 {
19158
2/2
✓ Branch 0 taken 6281 times.
✓ Branch 1 taken 2192 times.
8473 for(int32_t j=0; j<guys.Count(); j++)
19159 {
19160
3/4
✓ Branch 0 taken 1171 times.
✓ Branch 1 taken 5110 times.
✓ Branch 2 taken 1171 times.
✗ Branch 3 not taken.
6281 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
19161 {
19162 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
19163 return; // No point deleting it. A script might be toying with it in some way.
19164 else
19165 guys.del(j);
19166 }
19167 6281 }
19168
19169 2192 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
19170 2192 }
19171 402634 }
19172
19173 16139 void activate_fireball_statues()
19174 {
19175
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 15521 times.
16139 if(!(tmpscr->enemyflags&efFIREBALLS))
19176 {
19177 15521 return;
19178 }
19179
19180
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 108768 times.
109386 for(int32_t i=0; i<176; i++)
19181 {
19182 108768 activate_fireball_statue(i);
19183 108768 }
19184 16139 }
19185
19186 16139 void load_default_enemies()
19187 {
19188 16139 wallm_load_clk=frame-80;
19189
19190
2/2
✓ Branch 0 taken 15107 times.
✓ Branch 1 taken 1032 times.
16139 if(tmpscr->enemyflags&efZORA)
19191 {
19192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
1032 if(zoraID>=0)
19193 1032 addenemy(-16, -16, zoraID, 0);
19194 1032 }
19195
19196
2/2
✓ Branch 0 taken 16036 times.
✓ Branch 1 taken 103 times.
16139 if(tmpscr->enemyflags&efTRAP4)
19197 {
19198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(cornerTrapID>=0)
19199 {
19200 103 addenemy(32, 32, cornerTrapID, -14);
19201 103 addenemy(208, 32, cornerTrapID, -14);
19202 103 addenemy(32, 128, cornerTrapID, -14);
19203 103 addenemy(208, 128, cornerTrapID, -14);
19204 103 }
19205 103 }
19206
19207
2/2
✓ Branch 0 taken 177529 times.
✓ Branch 1 taken 16139 times.
193668 for(int32_t y=0; y<176; y+=16)
19208 {
19209
2/2
✓ Branch 0 taken 2840464 times.
✓ Branch 1 taken 177529 times.
3017993 for(int32_t x=0; x<256; x+=16)
19210 {
19211 2840464 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19212 2840464 int32_t cflag = MAPFLAG(x, y);
19213 2840464 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19214
19215
4/6
✓ Branch 0 taken 2840464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840393 times.
✓ Branch 3 taken 71 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840393 times.
2840464 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
19216 {
19217
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 61 times.
71 if(trapLOSHorizontalID>=0)
19218 61 addenemy(x, y, trapLOSHorizontalID, -14);
19219 71 }
19220
4/6
✓ Branch 0 taken 2840393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840357 times.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840357 times.
2840393 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
19221 {
19222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(trapLOSVerticalID>=0)
19223 36 addenemy(x, y, trapLOSVerticalID, -14);
19224 36 }
19225
4/6
✓ Branch 0 taken 2840357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840206 times.
✓ Branch 3 taken 151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840206 times.
2840357 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
19226 {
19227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(trapLOS4WayID>=0)
19228 {
19229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(addenemy(x, y, trapLOS4WayID, -14))
19230 151 guys.spr(guys.Count()-1)->dummy_int[1]=2;
19231 151 }
19232 151 }
19233
19234
4/6
✓ Branch 0 taken 2840206 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840139 times.
✓ Branch 3 taken 67 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840139 times.
2840206 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
19235 {
19236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(trapConstantHorizontalID>=0)
19237 67 addenemy(x, y, trapConstantHorizontalID, -14);
19238 67 }
19239
4/6
✓ Branch 0 taken 2840139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840059 times.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840059 times.
2840139 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
19240 {
19241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(trapConstantVerticalID>=0)
19242 80 addenemy(x, y, trapConstantVerticalID, -14);
19243 80 }
19244
19245
1/2
✓ Branch 0 taken 2840464 times.
✗ Branch 1 not taken.
2840464 if(ctype==cSPINTILE1)
19246 {
19247 // Awaken spinning tile
19248 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
19249 }
19250 2840464 }
19251 177529 }
19252
19253
2/2
✓ Branch 0 taken 16096 times.
✓ Branch 1 taken 43 times.
16139 if(tmpscr->enemyflags&efTRAP2)
19254 {
19255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(centerTrapID>=-1)
19256 {
19257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(addenemy(64, 80, centerTrapID, -14))
19258 43 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19259
19260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(addenemy(176, 80, centerTrapID, -14))
19261 43 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19262 43 }
19263 43 }
19264
19265
2/2
✓ Branch 0 taken 16072 times.
✓ Branch 1 taken 67 times.
16139 if(tmpscr->enemyflags&efROCKS)
19266 {
19267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(rockID>=0)
19268 {
19269 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19270 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19271 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19272 67 }
19273 67 }
19274
19275 16139 activate_fireball_statues();
19276 16139 }
19277
19278 20303935 void update_slope_combopos(int32_t lyr, int32_t pos)
19279 {
19280
2/4
✓ Branch 0 taken 20303935 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20303935 times.
20303935 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
19281 20303935 mapscr* s = FFCore.tempScreens[lyr];
19282 20303935 newcombo const& cmb = combobuf[s->data[pos]];
19283
19284 20303935 auto id = (176*lyr)+pos;
19285 20303935 auto it = slopes.find(id);
19286
19287 20303935 bool wasSlope = it!=slopes.end();
19288 20303935 bool isSlope = cmb.type == cSLOPE;
19289
19290
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 20303842 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
20303935 if(isSlope && !wasSlope)
19291 {
19292 93 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
19293 93 }
19294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20303842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20303842 else if(wasSlope && !isSlope)
19295 {
19296 slopes.erase(it);
19297 }
19298 20303935 }
19299 16294 void update_slope_comboposes()
19300 {
19301
2/2
✓ Branch 0 taken 114058 times.
✓ Branch 1 taken 16294 times.
130352 for(auto lyr = 0; lyr < 7; ++lyr)
19302 {
19303
2/2
✓ Branch 0 taken 20074208 times.
✓ Branch 1 taken 114058 times.
20188266 for(auto pos = 0; pos < 176; ++pos)
19304 20074208 update_slope_combopos(lyr,pos);
19305 114058 }
19306 16294 }
19307
19308 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
19309 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
19310 293866 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
19311 {
19312 293866 delete_fireball_shooter(s, pos);
19313 293866 }
19314
19315 //Placeholder in case we need it.
19316 void screen_ffc_modify_preroutine(word index)
19317 {
19318 return;
19319 }
19320
19321 // Everything that must be done after we change a screen's combo to another combo. -L
19322 293866 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
19323 {
19324 293866 s->valid |= mVALID;
19325 293866 activate_fireball_statue(pos);
19326
19327
2/2
✓ Branch 0 taken 293772 times.
✓ Branch 1 taken 94 times.
293866 if(combobuf[s->data[pos]].type==cSPINTILE1)
19328 {
19329 // Awaken spinning tile
19330 94 awaken_spinning_tile(s,pos);
19331 94 }
19332 293866 int32_t lyr = -1;
19333
2/2
✓ Branch 0 taken 89735 times.
✓ Branch 1 taken 204131 times.
293866 if(s == tmpscr) lyr = 0;
19334
2/2
✓ Branch 0 taken 64139 times.
✓ Branch 1 taken 479085 times.
543224 else for(size_t q = 0; q < 6; ++q)
19335 {
19336
2/2
✓ Branch 0 taken 25596 times.
✓ Branch 1 taken 453489 times.
479085 if(s == tmpscr2+q)
19337 {
19338 25596 lyr = q+1;
19339 25596 break;
19340 }
19341 453489 }
19342
2/2
✓ Branch 0 taken 64139 times.
✓ Branch 1 taken 229727 times.
293866 if(lyr > -1)
19343 229727 update_slope_combopos(lyr,pos);
19344 293866 }
19345
19346 4358513 void screen_ffc_modify_postroutine(word index)
19347 {
19348 4358513 ffcdata& ff = tmpscr->ffcs[index];
19349 4358513 newcombo const& cmb = combobuf[ff.data];
19350
19351 4358513 auto id = (176*7)+int32_t(index);
19352 4358513 auto it = slopes.find(id);
19353
19354 4358513 bool wasSlope = it!=slopes.end();
19355
1/2
✓ Branch 0 taken 4358513 times.
✗ Branch 1 not taken.
4358513 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER);
19356
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4358513 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4358513 if(isSlope && !wasSlope)
19357 {
19358 slopes.try_emplace(id, nullptr, &ff, id);
19359 }
19360
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4358513 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4358513 else if(wasSlope && !isSlope)
19361 {
19362 slopes.erase(it);
19363 }
19364
19365 4358513 tmpscr->ffcCountMarkDirty();
19366 4358513 }
19367
19368 4320 void screen_combo_modify_pre(int32_t cid)
19369 {
19370
2/2
✓ Branch 0 taken 30240 times.
✓ Branch 1 taken 4320 times.
34560 for(auto lyr = 0; lyr < 7; ++lyr)
19371 {
19372 30240 mapscr* t = FFCore.tempScreens[lyr];
19373
2/2
✓ Branch 0 taken 5322240 times.
✓ Branch 1 taken 30240 times.
5352480 for(int32_t i = 0; i < 176; i++)
19374 {
19375
2/2
✓ Branch 0 taken 5317845 times.
✓ Branch 1 taken 4395 times.
5322240 if(t->data[i] == cid)
19376 {
19377 4395 screen_combo_modify_preroutine(t,i);
19378 4395 }
19379 5322240 }
19380 30240 }
19381 4320 }
19382 4320 void screen_combo_modify_post(int32_t cid)
19383 {
19384
2/2
✓ Branch 0 taken 30240 times.
✓ Branch 1 taken 4320 times.
34560 for(auto lyr = 0; lyr < 7; ++lyr)
19385 {
19386 30240 mapscr* t = FFCore.tempScreens[lyr];
19387
2/2
✓ Branch 0 taken 5322240 times.
✓ Branch 1 taken 30240 times.
5352480 for(int32_t i = 0; i < 176; i++)
19388 {
19389
2/2
✓ Branch 0 taken 5317845 times.
✓ Branch 1 taken 4395 times.
5322240 if(t->data[i] == cid)
19390 {
19391 4395 screen_combo_modify_postroutine(t,i);
19392 4395 }
19393 5322240 }
19394 30240 }
19395
2/2
✓ Branch 0 taken 552960 times.
✓ Branch 1 taken 4320 times.
557280 for(word ind = 0; ind < MAXFFCS; ++ind)
19396 {
19397
1/2
✓ Branch 0 taken 552960 times.
✗ Branch 1 not taken.
552960 if(tmpscr->ffcs[ind].data == cid)
19398 screen_ffc_modify_postroutine(ind);
19399 552960 }
19400 4320 }
19401
19402 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
19403 {
19404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
19405 94 }
19406
19407
19408 // It stands for next_side_pos
19409 9987 void nsp(bool random)
19410 // moves sle_x and sle_y to the next position
19411 {
19412
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 6726 times.
9987 if(random)
19413 {
19414
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
19415 {
19416 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
19417 1634 sle_y = (zc_oldrand()%10)*16;
19418 1634 }
19419 else
19420 {
19421 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
19422 1627 sle_x = (zc_oldrand()%15)*16;
19423 }
19424
19425 3261 return;
19426 }
19427
19428
2/2
✓ Branch 0 taken 5084 times.
✓ Branch 1 taken 1642 times.
6726 if(sle_x==0)
19429 {
19430
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 146 times.
1642 if(sle_y<160)
19431 1496 sle_y+=16;
19432 else
19433 146 sle_x+=16;
19434 1642 }
19435
2/2
✓ Branch 0 taken 2122 times.
✓ Branch 1 taken 2962 times.
5084 else if(sle_y==160)
19436 {
19437
2/2
✓ Branch 0 taken 1985 times.
✓ Branch 1 taken 137 times.
2122 if(sle_x<240)
19438 1985 sle_x+=16;
19439 else
19440 137 sle_y-=16;
19441 2122 }
19442
2/2
✓ Branch 0 taken 1288 times.
✓ Branch 1 taken 1674 times.
2962 else if(sle_x==240)
19443 {
19444
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 123 times.
1288 if(sle_y>0)
19445 1165 sle_y-=16;
19446 else
19447 123 sle_x-=16;
19448 1288 }
19449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1674 times.
1674 else if(sle_y==0)
19450 {
19451
1/2
✓ Branch 0 taken 1674 times.
✗ Branch 1 not taken.
1674 if(sle_x>0)
19452 1674 sle_x-=16;
19453 else
19454 sle_y+=16;
19455 1674 }
19456 9987 }
19457
19458 1932 int32_t next_side_pos(bool random)
19459 // moves sle_x and sle_y to the next available position
19460 // returns the direction the enemy should face
19461 {
19462 bool blocked;
19463 1932 int32_t c=0;
19464
19465 1932 do
19466 {
19467
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 9862 times.
9987 nsp(c>35 ? false : random);
19468
3/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 8056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
11918 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
19469
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
19470
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1931 times.
✗ Branch 3 not taken.
1931 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
19471
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
1931 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
19472 1931 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
19473
19474
2/2
✓ Branch 0 taken 9986 times.
✓ Branch 1 taken 1 times.
9987 if(++c>50)
19475 1 return -1;
19476
2/2
✓ Branch 0 taken 8055 times.
✓ Branch 1 taken 1931 times.
9986 }
19477 9986 while(blocked);
19478
19479 1931 int32_t dir=0;
19480
19481
2/2
✓ Branch 0 taken 1354 times.
✓ Branch 1 taken 577 times.
1931 if(sle_x==0) dir=right;
19482
19483
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 501 times.
1931 if(sle_y==0) dir=down;
19484
19485
2/2
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 542 times.
1931 if(sle_x==240) dir=left;
19486
19487
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 if(sle_y==168) dir=up;
19488
19489 1931 return dir;
19490 1932 }
19491
19492 bool can_side_load(int32_t id)
19493 {
19494 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19495 {
19496 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()");
19497 return false;
19498 }
19499 switch(guysbuf[id].family) //id&0x0FFF)
19500 {
19501 //case eTEK1:
19502 //case eTEK2:
19503 //case eTEK3:
19504 //case eLEV1:
19505 //case eLEV2:
19506 //case eLEV3:
19507 //case eRAQUAM:
19508 //case eLAQUAM:
19509 //case eDODONGO:
19510 //case eMANHAN:
19511 //case eGLEEOK1:
19512 //case eGLEEOK2:
19513 //case eGLEEOK3:
19514 //case eGLEEOK4:
19515 //case eDIG1:
19516 //case eDIG3:
19517 //case eGOHMA1:
19518 //case eGOHMA2:
19519 //case eCENT1:
19520 //case eCENT2:
19521 //case ePATRA1:
19522 //case ePATRA2:
19523 //case eGANON:
19524 //case eMANHAN2:
19525 //case eCEILINGM: later
19526 //case eFLOORM: later
19527 //case ePATRABS:
19528 //case ePATRAL2:
19529 //case ePATRAL3:
19530 //case eGLEEOK1F:
19531 //case eGLEEOK2F:
19532 //case eGLEEOK3F:
19533 //case eGLEEOK4F:
19534 //case eDODONGOBS:
19535 //case eDODONGOF:
19536 //case eGOHMA3:
19537 //case eGOHMA4:
19538 //case eSHOOTMAGIC:
19539 //case eSHOOTROCK:
19540 //case eSHOOTSPEAR:
19541 //case eSHOOTSWORD:
19542 //case eSHOOTFLAME:
19543 //case eSHOOTFLAME2:
19544 //case eSHOOTFBALL:
19545 case eeTEK:
19546 case eeLEV:
19547 case eeAQUA:
19548 case eeDONGO:
19549 case eeMANHAN:
19550 case eeGLEEOK:
19551 case eeDIG:
19552 case eeGHOMA:
19553 case eeLANM:
19554 case eePATRA:
19555 case eeGANON:
19556 case eePROJECTILE:
19557 return false;
19558 break;
19559 }
19560
19561 return true;
19562 }
19563
19564 static bool script_sle = false;
19565 static int32_t sle_pattern = 0;
19566 void script_side_load_enemies()
19567 {
19568 if(script_sle || sle_clk) return;
19569 sle_cnt = 0;
19570 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19571 ++sle_cnt;
19572 script_sle = true;
19573 sle_pattern = tmpscr->pattern;
19574 sle_clk = 0;
19575 }
19576
19577 42952 void side_load_enemies()
19578 {
19579
3/4
✓ Branch 0 taken 42952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 578 times.
42952 if(!script_sle && sle_clk==0)
19580 {
19581 578 sle_pattern = tmpscr->pattern;
19582 578 sle_cnt = 0;
19583 578 int32_t guycnt = 0;
19584 578 int16_t s = (currmap<<7)+currscr;
19585 578 bool beenhere=false;
19586 578 bool reload=true;
19587 578 bool unbeatablereload = true;
19588
19589 578 load_default_enemies();
19590
19591
2/2
✓ Branch 0 taken 3468 times.
✓ Branch 1 taken 578 times.
4046 for(int32_t i=0; i<6; i++)
19592
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 178 times.
3646 if(visited[i]==s)
19593 178 beenhere=true;
19594
19595
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 400 times.
578 if(!beenhere)
19596 {
19597 400 visited[vhead]=s;
19598 400 vhead = (vhead+1)%6;
19599 400 }
19600
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 39 times.
178 else if(game->guys[s]==0)
19601 {
19602 39 sle_cnt=0;
19603 39 reload=false;
19604 39 }
19605
19606
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 539 times.
578 if(reload)
19607 {
19608 539 sle_cnt = game->guys[s];
19609
19610
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✓ Branch 2 taken 362 times.
✓ Branch 3 taken 177 times.
539 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
19611 539 || sle_cnt==0)
19612 {
19613
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 981 times.
✓ Branch 2 taken 806 times.
✓ Branch 3 taken 177 times.
983 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19614 806 ++sle_cnt;
19615 177 }
19616
3/4
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 400 times.
✗ Branch 3 not taken.
539 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19617 {
19618 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
19619 {
19620 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
19621 {
19622 unbeatablereload = false;
19623 }
19624 }
19625 if (unbeatablereload)
19626 {
19627 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19628 {
19629 ++sle_cnt;
19630 }
19631 }
19632 }
19633 539 }
19634
19635
2/4
✓ Branch 0 taken 578 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 578 times.
578 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
19636 {
19637 sle_cnt = 0;
19638
19639 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19640 ++sle_cnt;
19641 }
19642
19643
2/2
✓ Branch 0 taken 1889 times.
✓ Branch 1 taken 578 times.
2467 for(int32_t i=0; i<sle_cnt; i++)
19644 1889 ++guycnt;
19645
19646 578 game->guys[s] = guycnt;
19647 578 }
19648
19649
2/2
✓ Branch 0 taken 41020 times.
✓ Branch 1 taken 1932 times.
42952 if((++sle_clk+8)%24 == 0)
19650 {
19651 1932 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
19652
19653
4/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 1739 times.
1932 if(dir==-1 || tooclose(sle_x,sle_y,32))
19654 {
19655 193 return;
19656 }
19657
19658 1739 int32_t enemy_slot=guys.Count();
19659
19660
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1739 times.
1739 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
19661 sle_cnt--;
19662
19663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(sle_cnt > 0)
19664 {
19665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
19666 {
19667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19668 {
19669 1739 guys.spr(enemy_slot)->dir = dir;
19670 1739 }
19671
1/2
✓ Branch 0 taken 1739 times.
✗ Branch 1 not taken.
1739 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19672 {
19673 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19674 {
19675 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19676 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19677 }
19678 }
19679 1739 }
19680 1739 }
19681 1739 }
19682
19683
2/2
✓ Branch 0 taken 42248 times.
✓ Branch 1 taken 511 times.
42759 if(sle_cnt<=0)
19684 {
19685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 511 times.
511 if(script_sle)
19686 script_sle = false;
19687 511 else loaded_enemies=true;
19688 511 sle_clk = 0;
19689 511 }
19690 42952 }
19691
19692 1125376 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
19693 {
19694
19695
4/4
✓ Branch 0 taken 1025602 times.
✓ Branch 1 taken 99774 times.
✓ Branch 2 taken 99774 times.
✓ Branch 3 taken 1125376 times.
1125376 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19696 {
19697 //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]);
19698 199548 return false; //never 0, never OoB.
19699 }
19700 // No corner enemies
19701
6/6
✓ Branch 0 taken 964629 times.
✓ Branch 1 taken 160747 times.
✓ Branch 2 taken 38801 times.
✓ Branch 3 taken 1003430 times.
✓ Branch 4 taken 110860 times.
✓ Branch 5 taken 88688 times.
1125376 if((x==0 || x==240) && (y==0 || y==160))
19702
19703 199548 return false;
19704
19705 //Is a no spawn combo...
19706
3/4
✓ Branch 0 taken 1003426 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1003426 times.
1003430 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19707 4 return false;
19708
19709 // No enemies in dungeon walls
19710
10/10
✓ Branch 0 taken 632806 times.
✓ Branch 1 taken 370620 times.
✓ Branch 2 taken 561286 times.
✓ Branch 3 taken 71520 times.
✓ Branch 4 taken 489766 times.
✓ Branch 5 taken 71520 times.
✓ Branch 6 taken 403942 times.
✓ Branch 7 taken 85824 times.
✓ Branch 8 taken 85824 times.
✓ Branch 9 taken 318118 times.
1003426 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
19711 314688 return false;
19712
19713 // Too close
19714
4/4
✓ Branch 0 taken 69962 times.
✓ Branch 1 taken 618776 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 69939 times.
688738 if(tooclose(x,y,40) && t<11)
19715 69939 return false;
19716
19717 // Can't fly onto it?
19718
4/4
✓ Branch 0 taken 115623 times.
✓ Branch 1 taken 503176 times.
✓ Branch 2 taken 34519 times.
✓ Branch 3 taken 16220 times.
669538 if(isflier(tmpscr->enemy[i])&&
19719
2/2
✓ Branch 0 taken 115367 times.
✓ Branch 1 taken 256 times.
115623 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
19720
2/2
✓ Branch 0 taken 50739 times.
✓ Branch 1 taken 64628 times.
115367 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19721 16476 return false;
19722
19723 // Can't jump onto it?
19724 if
19725 (
19726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84754 times.
687077 guysbuf[tmpscr->enemy[i]].family==eeTEK
19727
19728
2/2
✓ Branch 0 taken 84754 times.
✓ Branch 1 taken 517569 times.
602323 &&
19729 (
19730
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19731
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 COMBOTYPE(x+8,y+8)==cNOENEMY||
19732
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 ispitfall(x+8,y+8)||
19733
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 MAPFLAG(x+8,y+8)==mfNOENEMY||
19734 84754 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19735 )
19736 )
19737 {
19738 return false;
19739 }
19740
19741 // Other off-limit combos
19742
6/6
✓ Branch 0 taken 503176 times.
✓ Branch 1 taken 99147 times.
✓ Branch 2 taken 418422 times.
✓ Branch 3 taken 84754 times.
✓ Branch 4 taken 239151 times.
✓ Branch 5 taken 179271 times.
1020745 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
19743
2/2
✓ Branch 0 taken 242814 times.
✓ Branch 1 taken 175608 times.
418422 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
19744 418422 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
19745 179271 return false;
19746
19747 // Don't ever generate enemies on these combos!
19748
3/4
✓ Branch 0 taken 422753 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422753 times.
423052 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19749 299 return false;
19750
19751 //BS Dodongos need at least 2 spaces.
19752
4/4
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 421789 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 2 times.
422753 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1))
19753 {
19754
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19755 ((x>224)||_walkflag(x+16,y+8, 2))&&
19756 ((y<16) ||_walkflag(x, y-8, 2))&&
19757 ((y>144)||_walkflag(x, y+24,2)))
19758 {
19759 return false;
19760 }
19761 2 }
19762
19763 422753 return true;
19764 1025602 }
19765
19766 79304 bool is_ceiling_pattern(int32_t i)
19767 {
19768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79304 times.
79304 return (i==pCEILING || i==pCEILINGR);
19769 }
19770
19771 5543 int32_t placeenemy(int32_t i)
19772 {
19773 5543 std::map<int32_t, int32_t> freeposcache;
19774 5543 int32_t frees = 0;
19775
19776
2/2
✓ Branch 0 taken 60973 times.
✓ Branch 1 taken 5543 times.
66516 for(int32_t y=0; y<176; y+=16)
19777 {
19778
2/2
✓ Branch 0 taken 975568 times.
✓ Branch 1 taken 60973 times.
1036541 for(int32_t x=0; x<256; x+=16)
19779 {
19780
3/4
✓ Branch 0 taken 975568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 391343 times.
✓ Branch 3 taken 584225 times.
975568 if(is_starting_pos(i,x,y,0))
19781 {
19782
1/2
✓ Branch 0 taken 391343 times.
✗ Branch 1 not taken.
391343 freeposcache[frees++] = (y&0xF0)+(x>>4);
19783 391343 }
19784 975568 }
19785 60973 }
19786
19787
2/2
✓ Branch 0 taken 5532 times.
✓ Branch 1 taken 11 times.
5543 if(frees > 0)
19788
2/4
✓ Branch 0 taken 5532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5532 times.
✗ Branch 3 not taken.
5532 return freeposcache[zc_oldrand()%frees];
19789
19790 11 return -1;
19791 5543 }
19792
19793 39969 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
19794 {
19795 39969 bool placed=false;
19796 39969 int32_t t=-1;
19797
19798 // First: enemy combo flags
19799
2/2
✓ Branch 0 taken 424419 times.
✓ Branch 1 taken 36953 times.
461372 for(int32_t sy=0; sy<176; sy+=16)
19800 {
19801
2/2
✓ Branch 0 taken 6768453 times.
✓ Branch 1 taken 421403 times.
7189856 for(int32_t sx=0; sx<256; sx+=16)
19802 {
19803 6768453 int32_t cflag = MAPFLAG(sx, sy);
19804 6768453 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
19805
19806
2/4
✓ Branch 0 taken 6768453 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6768453 times.
✗ Branch 3 not taken.
6768453 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19807 {
19808 if(!ok2add(tmpscr->enemy[i]))
19809 {
19810 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19811 }
19812 else
19813 {
19814 addenemy(sx,
19815 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19816 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19817
19818 ++guycnt;
19819
19820 placed=true;
19821 goto placed_enemy;
19822 }
19823 }
19824
19825
4/4
✓ Branch 0 taken 6765435 times.
✓ Branch 1 taken 3018 times.
✓ Branch 2 taken 6765435 times.
✓ Branch 3 taken 3018 times.
6768453 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19826 {
19827
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3016 times.
3018 if(!ok2add(tmpscr->enemy[i]))
19828 {
19829
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19830 2 }
19831 else
19832 {
19833 6032 addenemy(sx,
19834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3016 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19835
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3016 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19836
19837 3016 ++guycnt;
19838
19839 3016 placed=true;
19840 3016 goto placed_enemy;
19841 }
19842 2 }
19843 6765437 }
19844 421403 }
19845
19846 // Next: enemy pattern
19847
6/8
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 32061 times.
✓ Branch 2 taken 31495 times.
✓ Branch 3 taken 5458 times.
✓ Branch 4 taken 31495 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31495 times.
36953 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
19848 {
19849 31495 do
19850 {
19851
19852 // NES positions
19853 50119 pos%=9;
19854 50119 x=stx[loadside][pos];
19855 50119 y=sty[loadside][pos];
19856 50119 ++pos;
19857 50119 ++t;
19858
2/2
✓ Branch 0 taken 18624 times.
✓ Branch 1 taken 31495 times.
81614 }
19859
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 50034 times.
50119 while((t< 20) && !is_starting_pos(i,x,y,t));
19860 31495 }
19861
19862
4/4
✓ Branch 0 taken 31495 times.
✓ Branch 1 taken 5458 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 31410 times.
36953 if(t<0 || t >= 20) // above enemy pattern failed
19863 {
19864 // Final chance: find a random position anywhere onscreen
19865 5543 int32_t randpos = placeenemy(i);
19866
19867
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5532 times.
5543 if(randpos>-1)
19868 {
19869 5532 x=(randpos&15)<<4;
19870 5532 y= randpos&0xF0;
19871 5532 }
19872 else // All opportunities failed - abort
19873 {
19874 11 return;
19875 }
19876 5532 }
19877
19878 {
19879 36942 int32_t c=0;
19880 36942 c=clk;
19881
19882
2/2
✓ Branch 0 taken 5563 times.
✓ Branch 1 taken 31379 times.
36942 if(!slowguy(tmpscr->enemy[i]))
19883 31379 ++fastguys;
19884
2/2
✓ Branch 0 taken 851 times.
✓ Branch 1 taken 4712 times.
5563 else if(fastguys>0)
19885 851 c=-15*(i-fastguys+2);
19886 else
19887 4712 c=-15*(i+1);
19888
19889
4/6
✓ Branch 0 taken 7804 times.
✓ Branch 1 taken 29138 times.
✓ Branch 2 taken 7804 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7804 times.
36942 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19890 {
19891 // Special case for blue leevers
19892
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7802 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
7804 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1)
19893 2 c=-15*(i+1);
19894 else
19895 7802 c=-15;
19896 7804 }
19897
19898
2/2
✓ Branch 0 taken 36636 times.
✓ Branch 1 taken 306 times.
36942 if(!ok2add(tmpscr->enemy[i]))
19899 {
19900
4/6
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
306 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19901 306 }
19902 else
19903 {
19904
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36636 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36636 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19905 {
19906
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 36553 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
73272 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19907
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 36553 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
36636 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
19908
19909 36636 ++guycnt;
19910 36636 }
19911 }
19912
19913 36942 placed=true;
19914 36942 } // if(t < 20)
19915
19916 placed_enemy:
19917
19918 // I don't like this, but it seems to work...
19919 static bool foundCarrier;
19920
19921
2/2
✓ Branch 0 taken 30369 times.
✓ Branch 1 taken 9589 times.
39958 if(i==0)
19922 9589 foundCarrier=false;
19923
19924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39958 times.
39958 if(placed)
19925 {
19926
4/4
✓ Branch 0 taken 9589 times.
✓ Branch 1 taken 30369 times.
✓ Branch 2 taken 9446 times.
✓ Branch 3 taken 143 times.
39958 if(i==0 && tmpscr->enemyflags&efLEADER)
19927 {
19928 143 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19929
19930
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 7 times.
143 if(index!=-1)
19931 {
19932 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19933
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
136 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
19934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 if(index!=-1)
19935 {
19936 136 ((enemy*)guys.spr(index))->leader = true;
19937 136 }
19938 136 }
19939 143 }
19940
19941
4/4
✓ Branch 0 taken 39858 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 39824 times.
✓ Branch 3 taken 34 times.
39958 if(!foundCarrier && hasitem&(4|2))
19942 {
19943 34 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19944
19945
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0)
19946 {
19947 34 ((enemy*)guys.spr(index))->itemguy = true;
19948 34 foundCarrier=true;
19949 34 }
19950 34 }
19951 39958 }
19952 39969 }
19953
19954 bool scriptloadenemies()
19955 {
19956 loaded_enemies = true;
19957 if(script_sle || sle_clk) return false;
19958 if(tmpscr->pattern==pNOSPAWN) return false;
19959
19960 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19961 {
19962 script_side_load_enemies();
19963 return true;
19964 }
19965
19966 int32_t pos=zc_oldrand()%9;
19967 int32_t clk=-15,x=0,y=0,fastguys=0;
19968 int32_t i=0,guycnt=0;
19969 int32_t loadcnt = 10;
19970
19971 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19972 {
19973 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19974 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19975 if (guys.Count() > preguycount)
19976 {
19977 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19978 {
19979 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19980 {
19981 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19982 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19983 }
19984 }
19985 }
19986 --clk;
19987 }
19988 return true;
19989 }
19990
19991 7247780 void loadenemies()
19992 {
19993
3/4
✓ Branch 0 taken 7247780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 7205406 times.
7247780 if(script_sle || sle_clk)
19994 {
19995 42374 side_load_enemies();
19996 42374 return;
19997 }
19998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7205406 times.
7205406 if(tmpscr->pattern==pNOSPAWN) return;
19999
2/2
✓ Branch 0 taken 7189197 times.
✓ Branch 1 taken 16209 times.
7205406 if(loaded_enemies)
20000 7189197 return;
20001
20002 // check if it's the dungeon boss and it has been beaten before
20003
4/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 15961 times.
✓ Branch 2 taken 178 times.
✓ Branch 3 taken 70 times.
16209 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
20004 {
20005 70 loaded_enemies = true;
20006 70 return;
20007 }
20008
20009
4/4
✓ Branch 0 taken 15802 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 15561 times.
16139 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
20010 {
20011 578 side_load_enemies();
20012 578 return;
20013 }
20014
20015 15561 loaded_enemies=true;
20016
20017 // do enemies that are always loaded
20018 15561 load_default_enemies();
20019
20020 // dungeon basements
20021
20022 static byte dngn_enemy_x[4] = {32,96,144,208};
20023
20024
2/2
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 14882 times.
15561 if(currscr>=128)
20025 {
20026
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 if(DMaps[currdmap].flags&dmfCAVES) return;
20027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
20028 {
20029 for(int32_t i=0; i<10; i++)
20030 {
20031 if ( tmpscr->enemy[i] )
20032 {
20033 int32_t preguycount = guys.Count();
20034 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
20035 if (guys.Count() > preguycount)
20036 {
20037 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20038 {
20039 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20040 {
20041 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20042 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20043 }
20044 }
20045 }
20046 }
20047 }
20048 }
20049 else
20050 {
20051
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 340 times.
1700 for(int32_t i=0; i<4; i++)
20052 {
20053 1360 int32_t preguycount = guys.Count();
20054
2/2
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 396 times.
1360 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
20055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1360 times.
1360 if (guys.Count() > preguycount)
20056 {
20057
1/2
✓ Branch 0 taken 1360 times.
✗ Branch 1 not taken.
1360 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20058 {
20059 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20060 {
20061 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20062 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20063 }
20064 }
20065 1360 }
20066 1360 }
20067 }
20068 340 return;
20069 }
20070
20071 // check if it's been long enough to reload all enemies
20072
20073 14882 int32_t loadcnt = 10;
20074 14882 int16_t s = (currmap<<7)+currscr;
20075 14882 bool beenhere = false;
20076 14882 bool reload = true;
20077 14882 bool unbeatablereload = true;
20078
20079
2/2
✓ Branch 0 taken 89292 times.
✓ Branch 1 taken 14882 times.
104174 for(int32_t i=0; i<6; i++)
20080
2/2
✓ Branch 0 taken 84960 times.
✓ Branch 1 taken 4332 times.
93624 if(visited[i]==s)
20081 4332 beenhere = true;
20082
20083
2/2
✓ Branch 0 taken 4332 times.
✓ Branch 1 taken 10550 times.
14882 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
20084 {
20085 10550 visited[vhead]=s; //If not, it adds it to the array,
20086 10550 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
20087 10550 }
20088
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 2331 times.
4332 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
20089 {
20090 2331 loadcnt = 0; //It will tell it not to load any enemies,
20091 2331 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
20092 2331 }
20093
20094
2/2
✓ Branch 0 taken 2331 times.
✓ Branch 1 taken 12551 times.
14882 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
20095 {
20096 12551 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
20097
20098
2/4
✓ Branch 0 taken 4249 times.
✓ Branch 1 taken 8302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12551 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
20099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4249 times.
4249 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
20100 8302 loadcnt = 10; //That means all enemies need to be respawned.
20101
3/4
✓ Branch 0 taken 10550 times.
✓ Branch 1 taken 2001 times.
✓ Branch 2 taken 10550 times.
✗ Branch 3 not taken.
12551 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
20102 {
20103 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
20104 {
20105 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
20106 {
20107 unbeatablereload = false;
20108 }
20109 }
20110 if (unbeatablereload)
20111 {
20112 loadcnt = 10;
20113 }
20114 }
20115 12551 }
20116
20117
4/4
✓ Branch 0 taken 14232 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 14182 times.
14882 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
20118 700 loadcnt = 10; //All enemies also need to be respawned.
20119
20120 14882 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
20121 14882 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in its spawn poof.
20122 14882 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
20123
20124
4/4
✓ Branch 0 taken 6581 times.
✓ Branch 1 taken 48270 times.
✓ Branch 2 taken 39969 times.
✓ Branch 3 taken 14882 times.
54851 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
20125 {
20126 39969 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
20127 39969 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
20128
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 39652 times.
39969 if (guys.Count() > preguycount)
20129 {
20130
1/2
✓ Branch 0 taken 39652 times.
✗ Branch 1 not taken.
39652 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20131 {
20132 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20133 {
20134 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20135 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20136 }
20137 }
20138 39652 }
20139
20140 39969 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
20141 39969 }
20142
20143 14882 game->guys[s] = guycnt;
20144 //} //if(true)
20145 7247780 }
20146 147 void moneysign()
20147 {
20148 147 additem(48,108,iRupy,ipDUMMY);
20149 // textout(scrollbuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1);
20150 147 set_clip_state(pricesdisplaybuf, 0);
20151 147 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
20152 147 }
20153
20154 1571 void putprices(bool sign)
20155 {
20156
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1565 times.
1571 if(fadeclk > 0) return;
20157 // refresh what's under the prices
20158 // for(int32_t i=5; i<12; i++)
20159 // putcombo(scrollbuf,i<<4,112,tmpscr->data[112+i],tmpscr->cpage);
20160
20161 1565 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
20162 1565 int32_t step=32;
20163 1565 int32_t x=80;
20164
20165
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 1387 times.
1565 if(prices[2]==0)
20166 {
20167 1387 step<<=1;
20168
20169
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 27 times.
1387 if(prices[1]==0)
20170 {
20171 1360 x=112;
20172 1360 }
20173 1387 }
20174
20175
2/2
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 4695 times.
6260 for(int32_t i=0; i<3; i++)
20176 {
20177 // Kind of stupid, but it works: 100000 is used to indicate that an item
20178 // has a price of zero rather than there being no item.
20179 // 100000 isn't a valid price, so this doesn't cause problems.
20180
3/4
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 4003 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 692 times.
4695 if(prices[i]!=0 && prices[i]<100000)
20181 {
20182 char buf[8];
20183 692 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
20184
20185 692 int32_t l=(int32_t)strlen(buf);
20186 692 set_clip_state(pricesdisplaybuf, 0);
20187
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 671 times.
692 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
20188 692 }
20189
20190 4695 x+=step;
20191 4695 }
20192 1571 }
20193
20194 // Setting up special rooms
20195 // Also called when the Letter is used successfully.
20196 721 void setupscreen()
20197 {
20198 721 boughtsomething=false;
20199 721 int32_t t=currscr<128?0:1;
20200 721 word str=tmpscr[t].str;
20201
20202 // Prices are already set to 0 in dowarp()
20203
13/15
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 366 times.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 38 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 32 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13 times.
721 switch(tmpscr[t].room)
20204 {
20205 case rSP_ITEM: // special item
20206 105 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
20207 105 break;
20208
20209 case rINFO: // pay for info
20210 {
20211 14 int32_t count = 0;
20212 14 int32_t base = 88;
20213 14 int32_t step = 5;
20214
20215 14 moneysign();
20216
20217
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 42 times.
56 for(int32_t i=0; i<3; i++)
20218 {
20219
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(QMisc.info[tmpscr[t].catchall].str[i])
20220 {
20221 42 ++count;
20222 42 }
20223 else
20224 break;
20225 42 }
20226
20227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(count)
20228 {
20229
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count==1)
20230 {
20231 base = 88+32;
20232 }
20233
20234
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count==2)
20235 {
20236 step = 6;
20237 }
20238
20239
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
56 for(int32_t i=0; i < count; i++)
20240 {
20241 42 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
20242 42 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20243 42 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
20244
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(prices[i]==0)
20245 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20246 42 int32_t itemid = current_item_id(itype_wealthmedal);
20247
20248
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 if(itemid>=0 && prices[i]!=100000)
20249 {
20250 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20251 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20252 else
20253 prices[i]-=itemsbuf[itemid].misc1;
20254 prices[i]=vbound(prices[i], -99999, 0);
20255 if(prices[i]==0)
20256 prices[i]=100000;
20257 }
20258
20259
2/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
42 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
20260 prices[i]=-1;
20261 42 }
20262 14 }
20263
20264 14 break;
20265 }
20266
20267 case rMONEY: // secret money
20268 38 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
20269 38 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20270 38 break;
20271
20272 case rGAMBLE: // gambling
20273 7 prices[0]=prices[1]=prices[2]=-10;
20274 7 moneysign();
20275 7 additem(88,89,iRupy,ipMONEY+ipDUMMY);
20276 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20277 7 additem(120,89,iRupy,ipMONEY+ipDUMMY);
20278 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20279 7 additem(152,89,iRupy,ipMONEY+ipDUMMY);
20280 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
20281 7 break;
20282
20283 case rREPAIR: // door repair
20284
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20285 // }
20286 12 repaircharge=tmpscr[t].catchall;
20287 12 break;
20288
20289 case rMUPGRADE: // upgrade magic
20290 1 adjustmagic=true;
20291 1 break;
20292
20293 case rLEARNSLASH: // learn slash attack
20294 2 learnslash=true;
20295 2 break;
20296
20297 case rRP_HC: // heart container or red potion
20298 12 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
20299 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20300 12 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
20301 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20302 12 break;
20303
20304 case rP_SHOP: // potion shop
20305
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
20306 {
20307 12 str=0;
20308 12 break;
20309 }
20310
20311 [[fallthrough]];
20312 case rTAKEONE: // take one
20313 case rSHOP: // shop
20314 {
20315 127 int32_t count = 0;
20316 127 int32_t base = 88;
20317 127 int32_t step = 5;
20318
20319
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 126 times.
127 if(tmpscr[t].room != rTAKEONE)
20320 126 moneysign();
20321
20322 //count and align the stuff
20323
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 363 times.
461 for(int32_t i=0; i<3; ++i)
20324 {
20325
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 29 times.
363 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
20326 {
20327 334 ++count;
20328 334 }
20329 else
20330 {
20331 29 break;
20332 }
20333 334 }
20334
20335
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 18 times.
127 if(count==1)
20336 {
20337 18 base = 88+32;
20338 18 }
20339
20340
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 11 times.
127 if(count==2)
20341 {
20342 11 step = 6;
20343 11 }
20344
20345
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 127 times.
461 for(int32_t i=0; i<count; i++)
20346 {
20347 334 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
20348 334 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20349
20350
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 332 times.
334 if(tmpscr[t].room != rTAKEONE)
20351 {
20352 332 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
20353
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 if(prices[i]==0)
20354 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20355 332 int32_t itemid = current_item_id(itype_wealthmedal);
20356
20357
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
332 if(itemid>=0 && prices[i]!=100000)
20358 {
20359 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20360 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20361 else
20362 prices[i]+=itemsbuf[itemid].misc1;
20363 prices[i]=vbound(prices[i], 0, 99999);
20364 if(prices[i]==0)
20365 prices[i]=100000;
20366 }
20367
20368
2/4
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332 times.
✗ Branch 3 not taken.
332 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
20369 prices[i]=1;
20370 332 }
20371 334 }
20372
20373 127 break;
20374 }
20375 case rBOTTLESHOP: // bottle shop
20376 {
20377 int32_t count = 0;
20378 int32_t base = 88;
20379 int32_t step = 5;
20380
20381 moneysign();
20382 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
20383 //count and align the stuff
20384 for(int32_t i=0; i<3; ++i)
20385 {
20386 if(bst.fill[count] != 0)
20387 {
20388 ++count;
20389 }
20390 else
20391 {
20392 break;
20393 }
20394 }
20395
20396 if(count==1)
20397 {
20398 base = 88+32;
20399 }
20400
20401 if(count==2)
20402 {
20403 step = 6;
20404 }
20405
20406 for(int32_t i=0; i<count; i++)
20407 {
20408 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
20409 //{ Setup dummy item
20410 item* curItem = ((item*)items.spr(items.Count()-1));
20411 curItem->PriceIndex = i;
20412 newcombo const& cmb = combobuf[bst.comb[i]];
20413 curItem->o_tile = cmb.o_tile;
20414 curItem->o_cset = bst.cset[i];
20415 curItem->cs = curItem->o_cset;
20416 curItem->tile = cmb.o_tile;
20417 curItem->o_speed = cmb.speed;
20418 curItem->o_delay = 0;
20419 curItem->frames = cmb.frames;
20420 curItem->flip = cmb.flip;
20421 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
20422 curItem->pstring = 0;
20423 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
20424 curItem->flash = false;
20425 curItem->twohand = false;
20426 curItem->anim = true;
20427 curItem->hit_width=1;
20428 curItem->hyofs=4;
20429 curItem->hit_height=12;
20430 curItem->script=0;
20431 curItem->txsz=1;
20432 curItem->tysz=1;
20433 //}
20434
20435 prices[i] = bst.price[i];
20436 if(prices[i]==0)
20437 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20438 int32_t itemid = current_item_id(itype_wealthmedal);
20439
20440 if(itemid>=0 && prices[i]!=100000)
20441 {
20442 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20443 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20444 else
20445 prices[i]+=itemsbuf[itemid].misc1;
20446 prices[i]=vbound(prices[i], 0, 99999);
20447 if(prices[i]==0)
20448 prices[i]=100000;
20449 }
20450
20451 if((bst.price[i])>1 && prices[i]<1)
20452 prices[i]=1;
20453 }
20454
20455 break;
20456 }
20457
20458 case rBOMBS: // more bombs
20459 12 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20460 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20461 12 prices[0]=-tmpscr[t].catchall;
20462 12 break;
20463
20464 case rARROWS: // more arrows
20465 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20466 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20467 prices[0]=-tmpscr[t].catchall;
20468 break;
20469
20470 case rSWINDLE: // leave heart container or money
20471 13 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
20472 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20473 13 prices[0]=-1;
20474 13 additem(152,89,iRupy,ipDUMMY+ipMONEY);
20475 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20476 13 prices[1]=-tmpscr[t].catchall;
20477 13 break;
20478
20479 }
20480
20481
3/4
✓ Branch 0 taken 709 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 709 times.
721 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
20482 {
20483 12 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
20484 12 int32_t itemid = current_item_id(itype_wealthmedal);
20485
20486
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(itemid >= 0)
20487 {
20488 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20489 prices[i]*=(itemsbuf[itemid].misc1/100.0);
20490 else
20491 prices[i]+=itemsbuf[itemid].misc1;
20492 }
20493
20494
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(tmpscr[t].catchall>1 && prices[i]>-1)
20495 prices[i]=-1;
20496 12 }
20497
20498 721 putprices(false);
20499
20500
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 35 times.
721 if(str)
20501 {
20502 686 donewmsg(str);
20503 686 }
20504 else
20505 {
20506 35 Hero.unfreeze();
20507 }
20508 721 }
20509
20510 // Increments msgptr and returns the control code argument pointed at.
20511 658 word grab_next_argument()
20512 {
20513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658 times.
658 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
20514 658 byte val=MsgStrings[msgstr].s[++msgptr]-1;
20515 658 word ret=val;
20516
20517 // If an argument is succeeded by 255, then it's a three-byte argument -
20518 // between 254 and 65535 (or whatever the maximum actually is)
20519
1/2
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
658 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
20520
1/2
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
658 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
20521 {
20522 val=MsgStrings[msgstr].s[msgptr+2];
20523 word next=val;
20524 ret += 254*next;
20525 msgptr+=2;
20526 }
20527
20528 658 return ret;
20529 658 }
20530
20531 enum
20532 {
20533 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
20534 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
20535
20536 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
20537
20538 MNU_DATA_MAX
20539 };
20540 struct menu_choice
20541 {
20542 int32_t x, y;
20543 int32_t pos;
20544 int32_t upos, dpos, lpos, rpos;
20545 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
20546 {}
20547 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
20548 int32_t dpos, int32_t lpos, int32_t rpos)
20549 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
20550 {}
20551 };
20552 static int32_t msg_menu_data[MNU_DATA_MAX];
20553 static bool do_run_menu = false;
20554 bool do_end_str = false;
20555 static bool wait_advance = false;
20556 117 static std::map<int32_t, menu_choice> menu_options;
20557 19297 void clr_msg_data()
20558 {
20559 19297 do_end_str = false;
20560 19297 wait_advance = false;
20561 19297 do_run_menu = false;
20562 19297 menu_options.clear();
20563 19297 memset(msg_menu_data, 0, sizeof(msg_menu_data));
20564 19297 }
20565
20566 static bool doing_name_insert = false;
20567 static char namebuf[9] = {0};
20568 static char* nameptr = NULL;
20569 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
20570 bool runMenuCursor()
20571 {
20572 clear_bitmap(msg_menu_bmp_buf);
20573 if(!menu_options.size())
20574 {
20575 msg_menu_data[MNU_CHOSEN] = 0;
20576 return true; //end menu
20577 }
20578 int32_t pos = msg_menu_data[MNU_CHOSEN];
20579 //If the cursor is at an invalid pos, find the first pos >= 0...
20580 if(menu_options.find(pos) == menu_options.end())
20581 {
20582 pos = 0;
20583 while(menu_options.find(pos) == menu_options.end())
20584 ++pos;
20585 }
20586 menu_choice* ch = &menu_options[pos];
20587
20588 bool pressed = true;
20589 if(rUp()) pos = ch->upos;
20590 else if(rDown()) pos = ch->dpos;
20591 else if(rLeft()) pos = ch->lpos;
20592 else if(rRight()) pos = ch->rpos;
20593 else pressed = false;
20594
20595 if(pressed)
20596 msg_menu_data[MNU_TIMER] = 1;
20597
20598 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
20599 bool held = false;
20600 if(hold_input)
20601 {
20602 held = true;
20603 if(Up()) pos = ch->upos;
20604 else if(Down()) pos = ch->dpos;
20605 else if(Left()) pos = ch->lpos;
20606 else if(Right()) pos = ch->rpos;
20607 else held = false;
20608 }
20609 //If the cursor is at an invalid pos, find the first pos >= 0...
20610 if(menu_options.find(pos) == menu_options.end())
20611 {
20612 pos = 0;
20613 while(menu_options.find(pos) == menu_options.end())
20614 ++pos;
20615 }
20616 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
20617 sfx(MsgStrings[msgstr].sfx);
20618
20619 ch = &menu_options[pos];
20620 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20621 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20622 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20623 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20624
20625 msg_menu_data[MNU_CHOSEN] = pos;
20626
20627 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20628 {
20629 rAbtn(); //Eat
20630 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20631 }
20632
20633 bool ret = (pressed || held) ? false : rAbtn();
20634 //Eat inputs
20635 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20636
20637 if(ret)
20638 menu_options.clear();
20639
20640 return ret;
20641 //false if pos changed this frame; no confirming while moving the cursor!
20642 }
20643
20644 184952 bool bottom_margin_clip()
20645 {
20646 185252 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20647
2/2
✓ Branch 0 taken 184652 times.
✓ Branch 1 taken 300 times.
184952 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20648 }
20649
20650 void update_msgstr();
20651 98407 bool parsemsgcode()
20652 {
20653
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 97806 times.
98407 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
20654 97806 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
20655
5/38
✗ Branch 0 not taken.
✓ Branch 1 taken 97457 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 310 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 10 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
97806 switch(c)
20656 {
20657 case MSGC_NEWLINE:
20658 {
20659 1 ssc_tile_hei = ssc_tile_hei_buf;
20660
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20661 1 ssc_tile_hei_buf = -1;
20662 1 cursor_y += thei + MsgStrings[msgstr].vspace;
20663 1 cursor_x=msg_margins[left];
20664 1 return true;
20665 }
20666
20667 case MSGC_COLOUR:
20668 {
20669 310 int32_t cset = (grab_next_argument());
20670 310 msgcolour = CSET(cset)+(grab_next_argument());
20671 310 return true;
20672 }
20673
20674 case MSGC_SHDCOLOR:
20675 {
20676 int32_t cset = (grab_next_argument());
20677 msg_shdcol = CSET(cset)+(grab_next_argument());
20678 return true;
20679 }
20680 case MSGC_SHDTYPE:
20681 {
20682 msg_shdtype = grab_next_argument();
20683 return true;
20684 }
20685
20686 case MSGC_SPEED:
20687 {
20688 28 msgspeed=grab_next_argument();
20689 28 return true;
20690 }
20691
20692 case MSGC_CTRUP:
20693 {
20694 int32_t a1 = grab_next_argument();
20695 int32_t a2 = grab_next_argument();
20696 game->change_counter(a2, a1);
20697 return true;
20698 }
20699
20700 case MSGC_CTRDN:
20701 {
20702 int32_t a1 = grab_next_argument();
20703 int32_t a2 = grab_next_argument();
20704 game->change_counter(-a2, a1);
20705 return true;
20706 }
20707
20708 case MSGC_CTRSET:
20709 {
20710 int32_t a1 = grab_next_argument();
20711 int32_t a2 = grab_next_argument();
20712 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20713 return true;
20714 }
20715
20716 case MSGC_CTRUPPC:
20717 case MSGC_CTRDNPC:
20718 case MSGC_CTRSETPC:
20719 {
20720 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
20721 int32_t counter = grab_next_argument();
20722 int32_t amount = grab_next_argument();
20723 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20724
20725 if(code==MSGC_CTRDNPC)
20726 amount*=-1;
20727
20728 if(code==MSGC_CTRSETPC)
20729 game->set_counter(amount, counter);
20730 else
20731 game->change_counter(amount, counter);
20732
20733 return true;
20734 }
20735
20736 case MSGC_GIVEITEM:
20737 {
20738 int32_t itemID = grab_next_argument();
20739
20740 getitem(itemID, true);
20741 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20742 {
20743 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20744 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) > 0;
20745 }
20746 return true;
20747 }
20748
20749
20750 case MSGC_WARP:
20751 {
20752 int32_t dmap = grab_next_argument();
20753 int32_t scrn = grab_next_argument();
20754 int32_t dx = grab_next_argument();
20755 int32_t dy = grab_next_argument();
20756 int32_t wfx = grab_next_argument();
20757 int32_t sfx = grab_next_argument();
20758 if(dx >= MAX_SCC_ARG) dx = -1;
20759 if(dy >= MAX_SCC_ARG) dy = -1;
20760 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, warpFlagDONTKILLMUSIC, 0);
20761 return true;
20762 }
20763
20764 case MSGC_SETSCREEND:
20765 {
20766 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20767 int32_t screen = grab_next_argument();
20768 int32_t reg = grab_next_argument();
20769 int32_t val = grab_next_argument();
20770 FFCore.set_screen_d(screen + dmap, reg, val);
20771 return true;
20772 }
20773 case MSGC_TAKEITEM:
20774 {
20775 int32_t itemID = grab_next_argument();
20776 if ( FFCore.doscript(ScriptType::Item, itemID) )
20777 {
20778 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20779 }
20780 takeitem(itemID);
20781 if ( game->forced_bwpn == itemID )
20782 {
20783 game->forced_bwpn = -1;
20784 } //not else if! -Z
20785 if ( game->forced_awpn == itemID )
20786 {
20787 game->forced_awpn = -1;
20788 }
20789 if ( game->forced_xwpn == itemID )
20790 {
20791 game->forced_xwpn = -1;
20792 } //not else if! -Z
20793 if ( game->forced_ywpn == itemID )
20794 {
20795 game->forced_ywpn = -1;
20796 }
20797 verifyBothWeapons();
20798 return true;
20799 }
20800
20801 case MSGC_SFX:
20802 {
20803 10 sfx((int32_t)grab_next_argument(),128);
20804 10 return true;
20805 }
20806
20807 case MSGC_MIDI:
20808 {
20809 int32_t music = (int32_t)(grab_next_argument());
20810
20811 if(music==0)
20812 music_stop();
20813 else
20814 jukebox(music+(ZC_MIDI_COUNT-1));
20815
20816 return true;
20817 }
20818
20819 case MSGC_NAME:
20820 {
20821 doing_name_insert = true;
20822 sprintf(namebuf, "%s", game->get_name());
20823 nameptr = namebuf;
20824 return true;
20825 }
20826
20827 case MSGC_FONT:
20828 {
20829 int fontid = grab_next_argument();
20830 int oh = text_height(msgfont);
20831 msgfont = get_zc_font(fontid);
20832 int nh = text_height(msgfont);
20833 int mh = std::max(oh,nh);
20834 if(mh > ssc_tile_hei_buf)
20835 ssc_tile_hei_buf = mh;
20836 return true;
20837 }
20838 case MSGC_RUN_FRZ_GENSCR:
20839 {
20840 word scr_id = grab_next_argument();
20841 bool force_redraw = grab_next_argument()!=0;
20842 if(force_redraw)
20843 {
20844 update_msgstr();
20845 draw_screen(tmpscr);
20846 }
20847 FFCore.runGenericFrozenEngine(scr_id);
20848 return true;
20849 }
20850 case MSGC_DRAWTILE:
20851 {
20852 int32_t tl = grab_next_argument();
20853 int32_t cs = grab_next_argument();
20854 int32_t t_wid = grab_next_argument();
20855 int32_t t_hei = grab_next_argument();
20856 int32_t fl = grab_next_argument();
20857
20858 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20859 {
20860 ssc_tile_hei = ssc_tile_hei_buf;
20861 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20862 ssc_tile_hei_buf = -1;
20863 cursor_y += thei + MsgStrings[msgstr].vspace;
20864 if(bottom_margin_clip()) return true;
20865 cursor_x=msg_margins[left];
20866 }
20867
20868 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20869 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20870 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20871 return true;
20872 }
20873
20874 case MSGC_GOTOIFRAND:
20875 {
20876 int32_t odds = (int32_t)(grab_next_argument());
20877
20878 if(!odds || !(zc_oldrand()%odds))
20879 goto switched;
20880
20881 (void)grab_next_argument();
20882 return true;
20883 }
20884
20885 case MSGC_GOTOIFGLOBAL:
20886 {
20887 int32_t arg = (int32_t)grab_next_argument();
20888 int32_t d = zc_min(7,arg);
20889 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20890 arg = (int32_t)grab_next_argument();
20891
20892 if(game->screen_d[s][d] >= arg)
20893 goto switched;
20894
20895 (void)grab_next_argument();
20896 return true;
20897 }
20898
20899 case MSGC_CHANGEPORTRAIT:
20900 {
20901 return true; //not implemented
20902 }
20903
20904 case MSGC_GOTOIFCREEND:
20905 {
20906 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20907 int32_t screen = grab_next_argument();
20908 int32_t reg = grab_next_argument();
20909 int32_t val = grab_next_argument();
20910 //int32_t nxtstr = grab_next_argument();
20911 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20912 {
20913 goto switched;
20914 }
20915 (void)grab_next_argument();
20916 return true;
20917 }
20918
20919 case MSGC_GOTOIF:
20920 {
20921 int32_t it = (int32_t)grab_next_argument();
20922
20923 if(unsigned(it)<MAXITEMS && game->item[it])
20924 goto switched;
20925
20926 (void)grab_next_argument();
20927 return true;
20928 }
20929
20930 case MSGC_GOTOIFCTR:
20931 {
20932 if(game->get_counter(grab_next_argument())>=grab_next_argument())
20933 goto switched;
20934
20935 (void)grab_next_argument();
20936 return true;
20937 }
20938
20939 case MSGC_GOTOIFCTRPC:
20940 {
20941 int32_t counter = grab_next_argument();
20942 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
20943
20944 if(game->get_counter(counter)>=amount)
20945 goto switched;
20946
20947 (void)grab_next_argument();
20948 return true;
20949 }
20950
20951 case MSGC_GOTOIFTRICOUNT:
20952 {
20953 if(TriforceCount() >= (int32_t)(grab_next_argument()))
20954 goto switched;
20955
20956 (void)grab_next_argument();
20957 return true;
20958 }
20959
20960 case MSGC_GOTOIFTRI:
20961 {
20962 int32_t lev = (int32_t)(grab_next_argument());
20963
20964 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20965 goto switched;
20966
20967 (void)grab_next_argument();
20968 return true;
20969 }
20970
20971 case MSGC_SETUPMENU:
20972 {
20973 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
20974 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
20975 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
20976 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
20977 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
20978 return true;
20979 }
20980
20981 case MSGC_MENUCHOICE:
20982 {
20983 int32_t pos = grab_next_argument();
20984 int32_t upos = grab_next_argument();
20985 int32_t dpos = grab_next_argument();
20986 int32_t lpos = grab_next_argument();
20987 int32_t rpos = grab_next_argument();
20988 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20989 {
20990 ssc_tile_hei = ssc_tile_hei_buf;
20991 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20992 ssc_tile_hei_buf = -1;
20993 cursor_y += thei + MsgStrings[msgstr].vspace;
20994 if(bottom_margin_clip()) break;
20995 cursor_x=msg_margins[left];
20996 }
20997
20998 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20999 upos, dpos, lpos, rpos);
21000
21001 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
21002 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
21003 return true;
21004 }
21005
21006 case MSGC_RUNMENU:
21007 {
21008 msg_menu_data[MNU_CHOSEN] = 0;
21009 msg_menu_data[MNU_CAN_CONFIRM] = 0;
21010 if(menu_options.size() < 1)
21011 return true;
21012 do_run_menu = true;
21013 return true;
21014 }
21015
21016 case MSGC_GOTOMENUCHOICE:
21017 {
21018 int32_t choice = grab_next_argument();
21019 if(msg_menu_data[MNU_CHOSEN] == choice)
21020 goto switched;
21021 (void)grab_next_argument();
21022 return true;
21023 }
21024
21025 case MSGC_ENDSTRING:
21026 {
21027 do_end_str = true;
21028 return true;
21029 }
21030 case MSGC_WAIT_ADVANCE:
21031 {
21032 wait_advance = true;
21033 linkedmsgclk = 51;
21034 return true;
21035 }
21036 case MSGC_TRIGSECRETS:
21037 {
21038 bool perm = (bool)grab_next_argument();
21039 hidden_entrance(0, true, false, -8);
21040 if(perm)
21041 setmapflag(mSECRET);
21042 return true;
21043 }
21044 case MSGC_SETSCREENSTATE:
21045 {
21046 int32_t flag = int32_t(grab_next_argument());
21047 if(unsigned(flag)>=mMAXIND)
21048 {
21049 Z_error("SCC 133: Flag %d is invalid\n", flag);
21050 return true;
21051 }
21052 bool state = bool(grab_next_argument());
21053 if(state)
21054 setmapflag(1<<flag);
21055 else
21056 unsetmapflag(1<<flag,true);
21057 return true;
21058 }
21059 case MSGC_SETSCREENSTATER:
21060 {
21061 int32_t map = (int32_t)grab_next_argument();
21062 int32_t scrid = (int32_t)grab_next_argument();
21063 if(map < 1 || map > map_count)
21064 {
21065 Z_error("SCC 134: Map %d is invalid\n", map);
21066 return true;
21067 }
21068 if(unsigned(scrid)>=0x80)
21069 {
21070 Z_error("SCC 134: Screen %d is invalid\n", scrid);
21071 return true;
21072 }
21073
21074 int32_t flag = int32_t(grab_next_argument());
21075 if(unsigned(flag)>=mMAXIND)
21076 {
21077 Z_error("SCC 134: Flag %d is invalid\n", flag);
21078 return true;
21079 }
21080 bool state = bool(grab_next_argument());
21081 if(state)
21082 setmapflag(mapind(map,scrid),1<<flag);
21083 else
21084 unsetmapflag(mapind(map,scrid),1<<flag,true);
21085 return true;
21086 }
21087 switched:
21088 int32_t lev = (int32_t)(grab_next_argument());
21089 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
21090 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
21091 {
21092 msgstr=lev;
21093 msgpos=msgptr=0;
21094 msgfont=setmsgfont();
21095 }
21096 else
21097 {
21098 donewmsg(lev);
21099 ssc_tile_hei_buf = -1;
21100 }
21101 msgptr--; // To counteract it being incremented after this routine is called.
21102 putprices(false);
21103 return true;
21104 }
21105
21106 97457 return false;
21107 98407 }
21108
21109 // Wraps the message string... probably.
21110 95975 void wrapmsgstr(char *s3)
21111 {
21112 95975 int32_t j=0;
21113
21114
2/2
✓ Branch 0 taken 9679 times.
✓ Branch 1 taken 86296 times.
95975 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21115 {
21116
2/2
✓ Branch 0 taken 2081 times.
✓ Branch 1 taken 7598 times.
9679 if(msgspace)
21117 {
21118 2081 char c = MsgStrings[msgstr].s[msgptr];
21119
4/6
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 1786 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1786 times.
✗ Branch 5 not taken.
2081 if(c != ' ' && c >= 32 && c <= 126)
21120 {
21121
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9806 times.
✓ Branch 2 taken 8026 times.
✓ Branch 3 taken 1786 times.
9812 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
21122 {
21123
3/4
✓ Branch 0 taken 7734 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7734 times.
8026 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
21124 8026 }
21125
21126 1786 s3[j] = 0;
21127 1786 msgspace = false;
21128 1786 }
21129 else
21130 {
21131 295 s3[0] = c;
21132 295 s3[1] = 0;
21133 }
21134 2081 }
21135 else
21136 {
21137 7598 s3[0] = MsgStrings[msgstr].s[msgptr];
21138 7598 s3[1] = 0;
21139
21140
2/2
✓ Branch 0 taken 5948 times.
✓ Branch 1 taken 1650 times.
7598 if(s3[0] == ' ') msgspace=true;
21141 }
21142 9679 }
21143 else
21144 {
21145 86296 s3[0] = MsgStrings[msgstr].s[msgptr];
21146 86296 s3[1] = 0;
21147 }
21148 95975 }
21149
21150 // Returns true if the pointer is at a string's
21151 // null terminator or a trailing space
21152 251744 bool atend(char const* str)
21153 {
21154 251744 int32_t i=0;
21155
21156
2/2
✓ Branch 0 taken 1563482 times.
✓ Branch 1 taken 251744 times.
1815226 while(str[i]==' ')
21157 1563482 i++;
21158
21159 251744 return str[i]=='\0';
21160 }
21161
21162 7286701 void putmsg()
21163 {
21164 7286701 bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0;
21165
2/2
✓ Branch 0 taken 259878 times.
✓ Branch 1 taken 7026823 times.
7286701 if(!msgorig) msgorig=msgstr;
21166
21167
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7286701 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7286701 if(wait_advance && linkedmsgclk < 1)
21168 linkedmsgclk = 1;
21169
2/2
✓ Branch 0 taken 7190564 times.
✓ Branch 1 taken 96137 times.
7286701 if(linkedmsgclk>0)
21170 {
21171
2/2
✓ Branch 0 taken 45486 times.
✓ Branch 1 taken 50651 times.
96137 if(linkedmsgclk==1)
21172 {
21173
5/6
✓ Branch 0 taken 45486 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44557 times.
✓ Branch 3 taken 929 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 44473 times.
45486 if(do_end_str||cAbtn()||cBbtn())
21174 {
21175 1013 do_end_str = false;
21176 1013 linkedmsgclk = 0;
21177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1013 times.
1013 if(wait_advance)
21178 {
21179 wait_advance = false;
21180 }
21181 else
21182 {
21183 1013 msgstr=MsgStrings[msgstr].nextstring;
21184 1013 ssc_tile_hei_buf = -1;
21185
3/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 836 times.
✓ Branch 2 taken 177 times.
✗ Branch 3 not taken.
1013 if(!msgstr && enqueued_str)
21186 {
21187 msgstr = enqueued_str;
21188 enqueued_str = 0;
21189 }
21190
2/2
✓ Branch 0 taken 836 times.
✓ Branch 1 taken 177 times.
1013 if(!msgstr)
21191 {
21192 177 msgfont=get_zc_font(font_zfont);
21193
21194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 if(tmpscr->room!=rGRUMBLE)
21195 177 blockpath=false;
21196
21197 177 dismissmsg();
21198 177 goto disappear;
21199 }
21200
21201 836 donewmsg(msgstr);
21202 836 putprices(false);
21203 }
21204 836 }
21205 45309 }
21206 else
21207 {
21208 50651 --linkedmsgclk;
21209 }
21210 95960 }
21211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7286524 times.
7286524 if(wait_advance) return; //Waiting for buttonpress
21212
21213
9/10
✓ Branch 0 taken 7286430 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 258769 times.
✓ Branch 3 taken 7027661 times.
✓ Branch 4 taken 125265 times.
✓ Branch 5 taken 133504 times.
✓ Branch 6 taken 64562 times.
✓ Branch 7 taken 60703 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 64562 times.
7286524 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
21214 {
21215
2/2
✓ Branch 0 taken 194207 times.
✓ Branch 1 taken 7027661 times.
7221868 if(!msgstr)
21216 7027661 msgorig=0;
21217
21218 7221868 msg_active = false;
21219 7221868 return;
21220 }
21221
21222 64656 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
21223
21224 char s3[145];
21225 int32_t tlength;
21226
21227 // Bypass the string with the B button!
21228
4/4
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 64325 times.
✓ Branch 2 taken 961 times.
✓ Branch 3 taken 63364 times.
64656 if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0)
21229 {
21230 //finish writing out the string
21231
4/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 77095 times.
✓ Branch 2 taken 1198 times.
✓ Branch 3 taken 75989 times.
77281 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
21232 {
21233
4/6
✓ Branch 0 taken 17002 times.
✓ Branch 1 taken 58987 times.
✓ Branch 2 taken 17002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17002 times.
✗ Branch 5 not taken.
75989 if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
21234 goto breakout; // break out if message speed was changed to non-zero
21235
4/6
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75989 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 75753 times.
75989 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21236 {
21237
1/2
✓ Branch 0 taken 75753 times.
✗ Branch 1 not taken.
75753 if(bottom_margin_clip())
21238 break;
21239
21240 75753 wrapmsgstr(s3);
21241
21242
2/2
✓ Branch 0 taken 20120 times.
✓ Branch 1 taken 55633 times.
75753 if(MsgStrings[msgstr].s[msgptr]==' ')
21243 {
21244 20120 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21245
21246
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 1347 times.
21510 if(cursor_x+tlength > (msg_w-msg_margins[right])
21247
5/6
✓ Branch 0 taken 1390 times.
✓ Branch 1 taken 18730 times.
✓ Branch 2 taken 1390 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1304 times.
✓ Branch 5 taken 43 times.
20120 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21248 43 ? true : strcmp(s3," ")!=0))
21249 {
21250 1347 ssc_tile_hei = ssc_tile_hei_buf;
21251
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21252 1347 ssc_tile_hei_buf = -1;
21253 1347 cursor_y += thei + MsgStrings[msgstr].vspace;
21254
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 if(bottom_margin_clip()) break;
21255 1347 cursor_x=msg_margins[left];
21256 1347 }
21257
21258 20120 char buf[2] = {0};
21259 20120 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21260
21261 20120 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21262
21263 20120 cursor_x+=tlength;
21264 20120 }
21265 else
21266 {
21267 55633 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21268
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 533 times.
56334 if(cursor_x+tlength > (msg_w-msg_margins[right])
21269
5/6
✓ Branch 0 taken 744 times.
✓ Branch 1 taken 54889 times.
✓ Branch 2 taken 701 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 576 times.
✗ Branch 5 not taken.
55633 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21270 168 ? true : strcmp(s3," ")!=0))
21271 {
21272 744 ssc_tile_hei = ssc_tile_hei_buf;
21273
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21274 744 ssc_tile_hei_buf = -1;
21275 744 cursor_y += thei + MsgStrings[msgstr].vspace;
21276
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(bottom_margin_clip()) break;
21277 744 cursor_x=msg_margins[left];
21278 744 }
21279
21280 55633 sfx(MsgStrings[msgstr].sfx);
21281
21282 55633 char buf[2] = {0};
21283 55633 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21284
21285 55633 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21286
21287 55633 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21288 55633 cursor_x += MsgStrings[msgstr].hspace;
21289 }
21290
21291 75753 msgpos++;
21292 75753 }
21293
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(do_run_menu)
21294 {
21295 if(runMenuCursor())
21296 {
21297 do_run_menu = false;
21298 }
21299 else break;
21300 }
21301
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(doing_name_insert)
21302 {
21303 if(*nameptr)
21304 {
21305 if(bottom_margin_clip())
21306 break;
21307
21308 char s3[9] = {0};
21309
21310 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21311 {
21312 strcpy(s3, nameptr);
21313 }
21314 else
21315 {
21316 s3[0] = *nameptr;
21317 s3[1] = 0;
21318 }
21319
21320 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21321
21322 if(cursor_x+tlength > (msg_w-msg_margins[right])
21323 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21324 ? true : strcmp(s3," ")!=0))
21325 {
21326 ssc_tile_hei = ssc_tile_hei_buf;
21327 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21328 ssc_tile_hei_buf = -1;
21329 cursor_y += thei + MsgStrings[msgstr].vspace;
21330 if(bottom_margin_clip()) break;
21331 cursor_x=msg_margins[left];
21332 }
21333
21334 sfx(MsgStrings[msgstr].sfx);
21335
21336 char buf[2] = {0};
21337 sprintf(buf,"%c",*nameptr);
21338
21339 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21340
21341 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21342 cursor_x += MsgStrings[msgstr].hspace;
21343 ++nameptr;
21344 continue; //don't advance the msgptr, as the next char in it was not processed!
21345 }
21346 else doing_name_insert = false;
21347 }
21348 75989 ++msgptr;
21349
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(do_end_str)
21350 goto strendcheck;
21351
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(wait_advance)
21352 return;
21353
2/2
✓ Branch 0 taken 74810 times.
✓ Branch 1 taken 1179 times.
75989 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21354 {
21355
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 776 times.
1179 if(MsgStrings[msgstr].nextstring)
21356 {
21357
1/2
✓ Branch 0 taken 776 times.
✗ Branch 1 not taken.
776 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21358 {
21359 msgstr=MsgStrings[msgstr].nextstring;
21360 msgpos=msgptr=0;
21361 msgfont=setmsgfont();
21362 }
21363 776 }
21364 1179 }
21365 }
21366
21367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1198 times.
1198 if (!do_run_menu)
21368 {
21369 1198 msgclk = 72;
21370 1198 msgpos = 10000;
21371 1198 }
21372 1198 }
21373 else
21374 63364 {
21375 breakout:
21376 63364 word tempspeed = msgspeed;
21377
1/2
✓ Branch 0 taken 63364 times.
✗ Branch 1 not taken.
63364 if (do_run_menu)
21378 tempspeed = 0;
21379
6/6
✓ Branch 0 taken 52672 times.
✓ Branch 1 taken 10692 times.
✓ Branch 2 taken 15055 times.
✓ Branch 3 taken 37617 times.
✓ Branch 4 taken 10249 times.
✓ Branch 5 taken 4806 times.
63364 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
21380 42423 return;
21381 }
21382
21383 // Start writing the string
21384
2/2
✓ Branch 0 taken 21530 times.
✓ Branch 1 taken 609 times.
22748 if(msgptr == 0)
21385 {
21386
2/2
✓ Branch 0 taken 609 times.
✓ Branch 1 taken 2415 times.
3024 while(MsgStrings[msgstr].s[msgptr]==' ')
21387 {
21388 2415 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21389
21390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
2456 if(cursor_x+tlength > (msg_w-msg_margins[right])
21391
4/6
✓ Branch 0 taken 2374 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
2415 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21392 ? 1 : strcmp(s3," ")!=0))
21393 {
21394 41 ssc_tile_hei = ssc_tile_hei_buf;
21395
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21396 41 ssc_tile_hei_buf = -1;
21397 41 cursor_y += thei + MsgStrings[msgstr].vspace;
21398
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if(bottom_margin_clip()) break;
21399 41 cursor_x=msg_margins[left];
21400 41 }
21401
21402 2415 cursor_x+=tlength;
21403 2415 ++msgptr;
21404 2415 ++msgpos;
21405
21406 // The "Continue From Previous" feature
21407
2/2
✓ Branch 0 taken 1047 times.
✓ Branch 1 taken 1368 times.
2415 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21408 {
21409
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(MsgStrings[msgstr].nextstring)
21410 {
21411 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21412 {
21413 msgstr=MsgStrings[msgstr].nextstring;
21414 msgpos=msgptr=0;
21415 msgfont=setmsgfont();
21416 }
21417 }
21418 1368 }
21419 }
21420 609 }
21421
21422 reparsesinglechar:
21423 // Continue printing the string!
21424
3/4
✓ Branch 0 taken 20335 times.
✓ Branch 1 taken 1804 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20335 times.
42474 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
21425 {
21426
4/6
✓ Branch 0 taken 20335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 113 times.
✓ Branch 5 taken 20222 times.
20335 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21427 {
21428 20222 wrapmsgstr(s3);
21429
21430 20222 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21431
21432
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 236 times.
20478 if(cursor_x+tlength > (msg_w-msg_margins[right])
21433
6/6
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 19962 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 4 times.
20222 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21434 20 ? true : strcmp(s3," ")!=0))
21435 {
21436 256 ssc_tile_hei = ssc_tile_hei_buf;
21437
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21438 256 ssc_tile_hei_buf = -1;
21439 256 cursor_y += thei + MsgStrings[msgstr].vspace;
21440
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(bottom_margin_clip()) goto strendcheck;
21441 256 cursor_x=msg_margins[left];
21442 //if(space) s3[0]=0;
21443 256 }
21444
21445 20222 sfx(MsgStrings[msgstr].sfx);
21446
21447 20222 char buf[2] = {0};
21448 20222 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21449
21450 20222 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21451
21452 20222 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21453 20222 cursor_x += MsgStrings[msgstr].hspace;
21454 20222 msgpos++;
21455 20222 }
21456
1/2
✓ Branch 0 taken 20335 times.
✗ Branch 1 not taken.
20335 if(do_end_str)
21457 goto strendcheck;
21458
1/2
✓ Branch 0 taken 20335 times.
✗ Branch 1 not taken.
20335 if(wait_advance)
21459 {
21460 ++msgptr;
21461 return;
21462 }
21463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20335 times.
20335 else if(do_run_menu)
21464 {
21465 if(runMenuCursor())
21466 {
21467 do_run_menu = false;
21468 ++msgptr;
21469 goto reparsesinglechar;
21470 }
21471 }
21472
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20335 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20335 else if(doing_name_insert && *nameptr)
21473 {
21474 char s3[9] = {0};
21475
21476 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21477 {
21478 strcpy(s3, nameptr);
21479 }
21480 else
21481 {
21482 s3[0] = *nameptr;
21483 s3[1] = 0;
21484 }
21485
21486 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21487
21488 if(cursor_x+tlength > (msg_w-msg_margins[right])
21489 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21490 ? true : strcmp(s3," ")!=0))
21491 {
21492 ssc_tile_hei = ssc_tile_hei_buf;
21493 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21494 ssc_tile_hei_buf = -1;
21495 cursor_y += thei + MsgStrings[msgstr].vspace;
21496 if(bottom_margin_clip()) goto strendcheck;
21497 cursor_x=msg_margins[left];
21498 }
21499
21500 sfx(MsgStrings[msgstr].sfx);
21501
21502 char buf[2] = {0};
21503 sprintf(buf,"%c",*nameptr);
21504
21505 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21506
21507 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21508 cursor_x += MsgStrings[msgstr].hspace;
21509 ++nameptr;
21510 }
21511 else
21512 {
21513 20335 doing_name_insert = false;
21514 20335 msgptr++;
21515
21516
2/2
✓ Branch 0 taken 19832 times.
✓ Branch 1 taken 503 times.
20335 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21517 {
21518
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 61 times.
503 if(MsgStrings[msgstr].nextstring)
21519 {
21520
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21521 {
21522 msgstr=MsgStrings[msgstr].nextstring;
21523 msgpos=msgptr=0;
21524 msgfont=setmsgfont();
21525 }
21526 61 }
21527 503 }
21528
21529
2/2
✓ Branch 0 taken 2981 times.
✓ Branch 1 taken 1011 times.
24327 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
21530
2/2
✓ Branch 0 taken 20288 times.
✓ Branch 1 taken 47 times.
20335 && (MsgStrings[msgstr].s[msgptr]==' ')
21531
2/2
✓ Branch 0 taken 3992 times.
✓ Branch 1 taken 16296 times.
20288 && (MsgStrings[msgstr].s[msgptr+1]==' '))
21532 {
21533
2/2
✓ Branch 0 taken 1011 times.
✓ Branch 1 taken 33320 times.
34331 while(MsgStrings[msgstr].s[msgptr]==' ')
21534 {
21535 33320 msgspace = true;
21536 33320 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21537
21538
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1440 times.
34783 if(cursor_x+tlength > (msg_w-msg_margins[right])
21539
4/6
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 31857 times.
✓ Branch 2 taken 1463 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
33320 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21540 23 ? true : strcmp(s3," ")!=0))
21541 {
21542 1463 ssc_tile_hei = ssc_tile_hei_buf;
21543
1/2
✓ Branch 0 taken 1463 times.
✗ Branch 1 not taken.
1463 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21544 1463 ssc_tile_hei_buf = -1;
21545 1463 cursor_y += thei + MsgStrings[msgstr].vspace;
21546
1/2
✓ Branch 0 taken 1463 times.
✗ Branch 1 not taken.
1463 if(bottom_margin_clip()) break;
21547 1463 cursor_x=msg_margins[left];
21548 1463 }
21549
21550 33320 cursor_x+=tlength;
21551 33320 ++msgpos;
21552 33320 ++msgptr;
21553
21554
2/2
✓ Branch 0 taken 3250 times.
✓ Branch 1 taken 30070 times.
33320 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21555 {
21556
2/2
✓ Branch 0 taken 25984 times.
✓ Branch 1 taken 4086 times.
30070 if(MsgStrings[msgstr].nextstring)
21557 {
21558
1/2
✓ Branch 0 taken 4086 times.
✗ Branch 1 not taken.
4086 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21559 {
21560 msgstr=MsgStrings[msgstr].nextstring;
21561 msgpos=msgptr=0;
21562 msgfont=setmsgfont();
21563 }
21564 4086 }
21565 30070 }
21566 }
21567 1011 }
21568 }
21569 20335 }
21570 strendcheck:
21571 // Done printing the string
21572
10/14
✓ Branch 0 taken 22139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20941 times.
✓ Branch 7 taken 1198 times.
✓ Branch 8 taken 20451 times.
✓ Branch 9 taken 490 times.
✓ Branch 10 taken 20451 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20056 times.
✓ Branch 13 taken 2083 times.
22139 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
21573 {
21574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2083 times.
2083 if(!do_end_str)
21575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2083 times.
2083 while(parsemsgcode()); // Finish remaining control codes
21576
21577 // Go to next string, or make it disappear by going to string 0.
21578
5/6
✓ Branch 0 taken 1246 times.
✓ Branch 1 taken 837 times.
✓ Branch 2 taken 1069 times.
✓ Branch 3 taken 177 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1069 times.
2083 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21579 {
21580 1014 linkedmsgclk=do_end_str?1:51;
21581 1014 }
21582
21583
2/2
✓ Branch 0 taken 1246 times.
✓ Branch 1 taken 837 times.
2083 if(MsgStrings[msgstr].nextstring==0)
21584 {
21585
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 1069 times.
1246 if(!get_qr(qr_MSGDISAPPEAR))
21586 1069 {
21587 disappear:
21588 1246 msg_active = false;
21589 1246 Hero.finishedmsg();
21590 1246 }
21591
21592
2/2
✓ Branch 0 taken 1411 times.
✓ Branch 1 taken 12 times.
1423 if(repaircharge)
21593 {
21594 // if (get_qr(qr_REPAIRFIX)) {
21595 // fixed_door=true;
21596 // }
21597 12 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
21598 12 repaircharge = 0;
21599 12 }
21600
21601
2/2
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 1 times.
1423 if(adjustmagic)
21602 {
21603
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_qr(qr_OLD_HALF_MAGIC))
21604 {
21605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_magicdrainrate())
21606 1 game->set_magicdrainrate(1);
21607 1 }
21608 else if(game->get_magicdrainrate() > 1)
21609 {
21610 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21611 }
21612 1 adjustmagic = false;
21613 1 sfx(WAV_SCALE);
21614
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21615 1 }
21616
21617
2/2
✓ Branch 0 taken 1421 times.
✓ Branch 1 taken 2 times.
1423 if(learnslash)
21618 {
21619 2 game->set_canslash(1);
21620 2 learnslash = false;
21621 2 sfx(WAV_SCALE);
21622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21623 2 }
21624 1423 }
21625 2260 }
21626 7286607 }
21627
21628 45302 int32_t message_more_y()
21629 {
21630 //Is the flag ticked, do we really want a message more y larger than 160?
21631
5/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45288 times.
✓ Branch 2 taken 45302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45288 times.
✓ Branch 5 taken 14 times.
45302 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21632 45302 msgy+=playing_field_offset;
21633 45302 return msgy;
21634 }
21635
21636 /*** Collision detection & handling ***/
21637
21638 7263312 void clear_script_one_frame_conditions()
21639 {
21640
2/2
✓ Branch 0 taken 21645616 times.
✓ Branch 1 taken 7263312 times.
28908928 for(int32_t j=0; j<guys.Count(); j++)
21641 {
21642 21645616 enemy *e = (enemy*)guys.spr(j);
21643
2/2
✓ Branch 0 taken 367975472 times.
✓ Branch 1 taken 21645616 times.
389621088 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21644 21645616 }
21645 7263312 }
21646
21647 7263164 void check_collisions()
21648 {
21649
2/2
✓ Branch 0 taken 2980512 times.
✓ Branch 1 taken 7263164 times.
10243676 for(int32_t i=0; i<Lwpns.Count(); i++)
21650 {
21651 2980512 weapon *w = (weapon*)Lwpns.spr(i);
21652
21653
8/8
✓ Branch 0 taken 2516103 times.
✓ Branch 1 taken 464409 times.
✓ Branch 2 taken 2107862 times.
✓ Branch 3 taken 408241 times.
✓ Branch 4 taken 2086549 times.
✓ Branch 5 taken 21313 times.
✓ Branch 6 taken 13640 times.
✓ Branch 7 taken 2072909 times.
2980512 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21654 {
21655
2/2
✓ Branch 0 taken 2062226 times.
✓ Branch 1 taken 7445354 times.
9507580 for(int32_t j=0; j<guys.Count(); j++)
21656 {
21657 7445354 enemy *e = (enemy*)guys.spr(j);
21658
21659 7445354 bool didhit = e->hit(w);
21660
2/2
✓ Branch 0 taken 7307623 times.
✓ Branch 1 taken 137731 times.
7445354 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21661 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21662 {
21663 // !(e->stunclk)
21664 137731 int32_t h = e->takehit(w);
21665
2/2
✓ Branch 0 taken 114502 times.
✓ Branch 1 taken 23229 times.
137731 if (h == -1)
21666 {
21667 23229 e->hitby[HIT_BY_LWEAPON] = i+1;
21668 23229 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
21669 23229 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21670
2/2
✓ Branch 0 taken 1663 times.
✓ Branch 1 taken 21566 times.
23229 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
21671 1663 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21672 23229 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21673 23229 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21674
21675 23229 }
21676 //we may need to handle this in special cases. -Z
21677
21678 //if h == stun or ignore
21679
21680 //if e->stun > DEFAULT_STUN -1 || !e->stun
21681 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
21682 ///! how about: if w->dead != bounce !
21683
21684 // NOT FOR PUBLIC RELEASE
21685 /*if(h==3) //Mirror shield
21686 {
21687 if (w->id==ewFireball || w->id==wRefFireball)
21688 {
21689 w->id=wRefFireball;
21690 switch(e->dir)
21691 {
21692 case up: e->angle += (PI - e->angle) * 2.0; break;
21693 case down: e->angle = -e->angle; break;
21694 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
21695 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
21696 // TODO: the following. -L.
21697 case l_up: break;
21698 case r_up: break;
21699 case l_down: break;
21700 case r_down: break;
21701 }
21702 }
21703 else
21704 {
21705 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
21706 w->dir ^= 1;
21707 if(w->dir&2)
21708 w->flip ^= 1;
21709 else
21710 w->flip ^= 2;
21711 }
21712 w->ignoreHero=false;
21713 }
21714 else*/
21715
2/2
✓ Branch 0 taken 107377 times.
✓ Branch 1 taken 30354 times.
137731 if(h)
21716 {
21717
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30354 if(e->switch_hooked && w->family_class == itype_switchhook)
21718 w->onhit(false, e, -1);
21719 30354 else w->onhit(false, e, h);
21720 30354 }
21721
21722
2/2
✓ Branch 0 taken 135422 times.
✓ Branch 1 taken 2309 times.
137731 if(h==2)
21723 {
21724 2309 break;
21725 }
21726 135422 }
21727
21728
2/2
✓ Branch 0 taken 7434671 times.
✓ Branch 1 taken 8374 times.
7443045 if(w->Dead())
21729 {
21730 8374 break;
21731 }
21732 7434671 }
21733
21734 // Item flags added in 2.55:
21735 // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP)
21736 // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21737 // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21738 // -V
21739
6/6
✓ Branch 0 taken 1760149 times.
✓ Branch 1 taken 312760 times.
✓ Branch 2 taken 1755673 times.
✓ Branch 3 taken 4476 times.
✓ Branch 4 taken 21925 times.
✓ Branch 5 taken 1733748 times.
2072909 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21740 {
21741 339161 int32_t itype, pitem = w->parentitem;
21742
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 312760 times.
✓ Branch 2 taken 21925 times.
✓ Branch 3 taken 4476 times.
339161 switch(w->id)
21743 {
21744 312760 case wBrang: itype = itype_brang; break;
21745 21925 case wArrow: itype = itype_arrow; break;
21746 case wHookshot:
21747 4476 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21748 4476 break;
21749 }
21750
2/2
✓ Branch 0 taken 334309 times.
✓ Branch 1 taken 4852 times.
339161 if(pitem < 0) pitem = current_item_id(itype);
21751
5/6
✓ Branch 0 taken 4476 times.
✓ Branch 1 taken 334685 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 4376 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
339161 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9))
21752 { //Swap with item
21753 for(int32_t j=0; j<items.Count(); j++)
21754 {
21755 if(items.spr(j)->hit(w))
21756 {
21757 item *theItem = ((item*)items.spr(j));
21758 bool priced = theItem->PriceIndex >-1;
21759 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21760 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21761 || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21762 {
21763 if(!Hero.switchhookclk)
21764 {
21765 hooked_combopos = -1;
21766 hooked_layerbits = 0;
21767 switching_object = theItem;
21768 theItem->switch_hooked = true;
21769 w->misc = 2;
21770 w->step = 0;
21771 theItem->clk2=256;
21772 Hero.doSwitchHook(game->get_switchhookstyle());
21773 if(QMisc.miscsfx[sfxSWITCHED])
21774 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21775 }
21776 }
21777 }
21778 }
21779 }
21780
6/6
✓ Branch 0 taken 21925 times.
✓ Branch 1 taken 317236 times.
✓ Branch 2 taken 318320 times.
✓ Branch 3 taken 296395 times.
✓ Branch 4 taken 317236 times.
✓ Branch 5 taken 296395 times.
339161 else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21781 {
21782
2/2
✓ Branch 0 taken 73578 times.
✓ Branch 1 taken 318320 times.
391898 for(int32_t j=0; j<items.Count(); j++)
21783 {
21784
2/2
✓ Branch 0 taken 69398 times.
✓ Branch 1 taken 4180 times.
73578 if(items.spr(j)->hit(w))
21785 {
21786 4180 item *theItem = ((item*)items.spr(j));
21787 4180 bool priced = theItem->PriceIndex >-1;
21788
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 4096 times.
4180 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21789
5/8
✓ Branch 0 taken 4180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4180 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3363 times.
✓ Branch 5 taken 817 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1858 times.
6038 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21790
4/6
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 1858 times.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2675 times.
4180 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced)))
21791 {
21792
1/2
✓ Branch 0 taken 1505 times.
✗ Branch 1 not taken.
5221 if(itemsbuf[theItem->id].collect_script)
21793 {
21794 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21795 }
21796
21797 1505 Hero.checkitems(j);
21798 1505 }
21799 4180 }
21800 73578 }
21801 318320 }
21802
2/2
✓ Branch 0 taken 4872 times.
✓ Branch 1 taken 15969 times.
613631 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21803 {
21804
2/2
✓ Branch 0 taken 3337 times.
✓ Branch 1 taken 15969 times.
19306 for(int32_t j=0; j<items.Count(); j++)
21805 {
21806
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 935 times.
3337 if(items.spr(j)->hit(w))
21807 {
21808 935 item *theItem = ((item*)items.spr(j));
21809 935 bool priced = theItem->PriceIndex >-1;
21810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 935 times.
935 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21811
4/6
✓ Branch 0 taken 935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 895 times.
✓ Branch 5 taken 40 times.
935 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21812
5/10
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 376 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 376 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
935 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21813 {
21814 559 int32_t pickup = theItem->pickup;
21815 559 int32_t id2 = theItem->id;
21816 559 int32_t pstr = theItem->pstring;
21817 559 int32_t pstr_flags = theItem->pickup_string_flags;
21818
21819 559 std::vector<int32_t> &ev = FFCore.eventData;
21820 559 ev.clear();
21821 559 ev.push_back(id2*10000);
21822 559 ev.push_back(pickup*10000);
21823 559 ev.push_back(pstr*10000);
21824 559 ev.push_back(pstr_flags*10000);
21825 559 ev.push_back(0);
21826 559 ev.push_back(theItem->getUID());
21827 559 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21828 559 ev.push_back(w->getUID());
21829
21830 559 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21831 559 bool nullify = ev[4] != 0;
21832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(nullify) continue;
21833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(w->id == wBrang)
21834 {
21835 559 w->onhit(false);
21836 559 }
21837
21838
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 37 times.
559 if(w->dragging==-1)
21839 {
21840 37 w->dead=1;
21841 37 theItem->clk2=256;
21842 37 w->dragging=j;
21843 37 theItem->is_dragged = true;
21844 37 }
21845 559 }
21846 935 }
21847 3337 }
21848 15969 }
21849 339161 }
21850 2072909 }
21851 2980512 }
21852 7263164 }
21853
21854 7263312 void dragging_item()
21855 {
21856
2/2
✓ Branch 0 taken 3041933 times.
✓ Branch 1 taken 7263312 times.
10305245 for(int32_t i=0; i<Lwpns.Count(); i++)
21857 {
21858 3041933 weapon *w = (weapon*)Lwpns.spr(i);
21859
21860
4/4
✓ Branch 0 taken 2722775 times.
✓ Branch 1 taken 319158 times.
✓ Branch 2 taken 3025626 times.
✓ Branch 3 taken 16307 times.
3041933 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT
21861 {
21862
3/4
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 15756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 551 times.
16307 if(w->dragging>=0 && w->dragging<items.Count())
21863 {
21864 551 item* dragItem = (item*)items.spr(w->dragging);
21865 551 dragItem->x=w->x;
21866 551 dragItem->y=w->y;
21867
21868 // Drag the Fairy enemy as well as the Fairy item
21869 551 int32_t id = dragItem->id;
21870
21871
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
551 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21872 {
21873 movefairynew2(w->x,w->y,*dragItem);
21874 }
21875 551 }
21876 16307 }
21877 3041933 }
21878 7263312 }
21879
21880 28 int32_t more_carried_items()
21881 {
21882 28 int32_t hasmorecarries = 0;
21883
21884
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 28 times.
59 for(int32_t i=0; i<items.Count(); i++)
21885 {
21886
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 28 times.
31 if(((item*)items.spr(i))->pickup & ipENEMY)
21887 {
21888 28 hasmorecarries++;
21889 28 }
21890 31 }
21891
21892 28 return hasmorecarries;
21893 }
21894
21895 // messy code to do the enemy-carrying-the-item thing
21896 7263312 void roaming_item()
21897 {
21898
4/4
✓ Branch 0 taken 13238 times.
✓ Branch 1 taken 7250074 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 13198 times.
7263312 if(!(hasitem&(4|2)) || !loaded_enemies)
21899 7250114 return;
21900
21901 // All enemies already dead upon entering a room?
21902
1/2
✓ Branch 0 taken 13198 times.
✗ Branch 1 not taken.
13198 if(guys.Count()==0)
21903 {
21904 return;
21905 }
21906
21907 // Lost track of the carrier?
21908
5/6
✓ Branch 0 taken 13198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13196 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 13187 times.
✓ Branch 5 taken 9 times.
13198 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
21909 13196 !((enemy*)guys.spr(guycarryingitem))->itemguy)
21910 {
21911 11 guycarryingitem=-1;
21912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 for(int32_t j=0; j<guys.Count(); j++)
21913 {
21914
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 11 times.
35 if(((enemy*)guys.spr(j))->itemguy)
21915 {
21916 11 guycarryingitem=j;
21917 11 break;
21918 }
21919 24 }
21920 11 }
21921
21922
2/2
✓ Branch 0 taken 13164 times.
✓ Branch 1 taken 34 times.
13198 if(hasitem&4)
21923 {
21924 34 guycarryingitem = -1;
21925
21926
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 34 times.
263 for(int32_t i=0; i<guys.Count(); i++)
21927 {
21928
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 34 times.
229 if(((enemy*)guys.spr(i))->itemguy)
21929 {
21930 34 guycarryingitem = i;
21931 34 }
21932 229 }
21933
21934
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(guycarryingitem == -1) //This happens when "default enemies" such as
21935 {
21936 return; //eSHOOTFBALL are alive but enemies from the list
21937 } //are not. Defer to HeroClass::checkspecial().
21938
21939 34 int32_t Item=tmpscr->item;
21940
21941 34 hasitem &= ~4;
21942
21943
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21944 {
21945 60 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
21946
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 8 times.
34 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21947 );
21948 34 hasitem |= 2;
21949 34 }
21950 else
21951 {
21952 return;
21953 }
21954 34 }
21955
21956
2/2
✓ Branch 0 taken 13953 times.
✓ Branch 1 taken 13198 times.
27151 for(int32_t i=0; i<items.Count(); i++)
21957 {
21958
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 13198 times.
13953 if(((item*)items.spr(i))->pickup&ipENEMY)
21959 {
21960
2/2
✓ Branch 0 taken 8390 times.
✓ Branch 1 taken 4808 times.
13198 if(get_qr(qr_HIDECARRIEDITEMS))
21961 {
21962 8390 items.spr(i)->x = -128; // Awfully inelegant, innit?
21963 8390 items.spr(i)->y = -128;
21964 8390 }
21965
2/4
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4808 times.
4808 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21966 {
21967
1/2
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
4808 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21968 {
21969 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21970 {
21971 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21972 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21973 }
21974 else
21975 {
21976 if(guys.spr(guycarryingitem)->extend >= 3)
21977 {
21978 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21979 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21980 }
21981 else
21982 {
21983 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21984 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21985 }
21986 }
21987 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21988 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21989 }
21990 else
21991 {
21992 4808 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21993 4808 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21994 4808 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21995 }
21996 4808 }
21997 13198 }
21998 13953 }
21999 7263312 }
22000
22001 bool enemy::IsBigAnim()
22002 {
22003 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
22004 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
22005 || anim == a4FRM8DIRB);
22006 }
22007 1329505 int32_t enemy::getFlashingCSet()
22008 {
22009 //Special cset for the dying sprite
22010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329505 times.
1329505 if(dying)
22011 {
22012 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
22013 return wpnsbuf[spr_death].csets & 15;
22014 else
22015 return (((clk2 + 5) >> 1) & 3) + 6;
22016 }
22017
22018 //Normal cset
22019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329505 times.
1329505 if (hclk <= 0)
22020 {
22021 //Special cset for the flashing animation
22022 if (flags2 & guy_flashing)
22023 return (frame & 3) + 6;
22024 return cs;
22025 }
22026
22027 //Hurt animations
22028
2/2
✓ Branch 0 taken 2916 times.
✓ Branch 1 taken 1326589 times.
1329505 if(family==eeGANON)
22029 2916 return (((hclk-1)>>1)&3)+6;
22030
4/4
✓ Branch 0 taken 1232717 times.
✓ Branch 1 taken 93872 times.
✓ Branch 2 taken 284481 times.
✓ Branch 3 taken 948236 times.
1326589 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
22031 948236 return (((hclk-1)>>1)&3)+6;
22032
22033 378353 return cs;
22034 1329505 }
22035
22036 45969818 bool enemy::is_hitflickerframe(bool olddrawing)
22037 {
22038
6/6
✓ Branch 0 taken 45947326 times.
✓ Branch 1 taken 22492 times.
✓ Branch 2 taken 2232586 times.
✓ Branch 3 taken 43714740 times.
✓ Branch 4 taken 1799101 times.
✓ Branch 5 taken 433485 times.
45969818 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
22039 45536333 return false;
22040
22041
3/4
✓ Branch 0 taken 273980 times.
✓ Branch 1 taken 159505 times.
✓ Branch 2 taken 273980 times.
✗ Branch 3 not taken.
433485 if (!olddrawing && !getCanFlicker())
22042 return false;
22043
22044 433485 int32_t fr = game->get_spriteflickerspeed();
22045
1/2
✓ Branch 0 taken 433485 times.
✗ Branch 1 not taken.
433485 if (fr == 0)
22046 return true;
22047 433485 return frame % (fr * 2) < fr;
22048 45969818 }
22049
22050 const char *old_guy_string[OLDMAXGUYS] =
22051 {
22052 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
22053 // 020
22054 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
22055 // 025
22056 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
22057 // 030
22058 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
22059 // 035
22060 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
22061 // 040
22062 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
22063 // 045
22064 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
22065 // 050
22066 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
22067 // 055
22068 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
22069 // 060
22070 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
22071 // 065
22072 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
22073 // 070
22074 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
22075 // 075
22076 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
22077 // 080
22078 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
22079 // 085
22080 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
22081 // 090
22082 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
22083 // 095
22084 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
22085 // 100
22086 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
22087 // 105
22088 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
22089 // 110
22090 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
22091 // 115
22092 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
22093 // 120
22094 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
22095 // 125
22096 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
22097 // 130
22098 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
22099 // 135
22100 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
22101 // 140
22102 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
22103 // 145
22104 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
22105 // 150
22106 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
22107 // 155
22108 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
22109 // 160
22110 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
22111 // 165
22112 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
22113 // 170
22114 "Pols Voice (Magic) ", "Pols Voice (Whistle) ", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
22115 // 175
22116 "Grappler Bug (HP) ", "Grappler Bug (MP) "
22117 };
22118